portal/build.gradle

222 lines
6.8 KiB
Groovy
Raw Normal View History

2019-02-06 17:41:48 +01:00
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2019-06-06 17:24:19 +02:00
import java.text.SimpleDateFormat
2019-02-05 22:18:15 +01:00
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
plugins {
2019-05-10 11:59:41 +02:00
id 'kotlin-multiplatform' version '1.3.31'
id 'kotlinx-serialization' version '1.3.31'
2019-02-05 22:18:15 +01:00
id "org.kravemir.gradle.sass" version "1.2.2"
2019-06-06 17:24:19 +02:00
id "com.github.johnrengelman.shadow" version "5.0.0"
2019-02-05 22:18:15 +01:00
}
group "de.kif"
version "0.1.0"
repositories {
2019-05-30 12:32:40 +02:00
mavenCentral()
2019-02-05 22:18:15 +01:00
jcenter()
2019-05-29 12:44:33 +02:00
maven { url 'https://jitpack.io' }
2019-05-24 14:29:10 +02:00
maven { url "https://dl.bintray.com/kotlin/ktor" }
maven { url "https://dl.bintray.com/jetbrains/markdown" }
2019-02-05 22:18:15 +01:00
maven { url "https://kotlin.bintray.com/kotlinx" }
2019-05-10 11:59:41 +02:00
maven { url "https://kotlin.bintray.com/kotlin-js-wrappers" }
2019-05-30 12:32:40 +02:00
maven { url "https://dl.bintray.com/soywiz/soywiz" }
2019-02-05 22:18:15 +01:00
}
2019-05-10 11:59:41 +02:00
def ktor_version = '1.1.5'
def serialization_version = '0.11.0'
2019-05-17 22:39:42 +02:00
def observable_version = '0.9.3'
2019-05-30 12:32:40 +02:00
def klockVersion = "1.4.0"
2019-02-05 22:18:15 +01:00
kotlin {
2019-04-04 17:38:31 +02:00
jvm() {
compilations.all {
kotlinOptions {
2019-05-29 12:44:33 +02:00
jvmTarget = "1.8"
2019-04-04 17:38:31 +02:00
freeCompilerArgs += [
"-Xuse-experimental=io.ktor.util.KtorExperimentalAPI"
]
}
}
}
2019-02-05 22:18:15 +01:00
js() {
compilations.all {
kotlinOptions {
moduleKind = "umd"
sourceMap = true
metaInfo = true
}
}
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
2019-05-17 22:39:42 +02:00
implementation "de.westermann:KObserve-metadata:$observable_version"
2019-05-30 12:32:40 +02:00
implementation "com.soywiz:klock-metadata:$klockVersion"
implementation "com.soywiz:klock-locale-metadata:$klockVersion"
2019-02-05 22:18:15 +01:00
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
jvmMain {
dependencies {
implementation kotlin('stdlib-jdk8')
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
implementation "io.ktor:ktor-server-netty:$ktor_version"
implementation "io.ktor:ktor-auth:$ktor_version"
implementation "io.ktor:ktor-server-sessions:$ktor_version"
2019-05-10 11:59:41 +02:00
implementation "io.ktor:ktor-websockets:$ktor_version"
implementation "io.ktor:ktor-jackson:$ktor_version"
2019-05-10 11:59:41 +02:00
implementation 'org.jetbrains:kotlin-css-jvm:1.0.0-pre.70-kotlin-1.3.21'
2019-02-05 22:18:15 +01:00
implementation "io.ktor:ktor-html-builder:$ktor_version"
2019-05-31 11:40:17 +02:00
implementation "io.ktor:ktor-client-apache:$ktor_version"
2019-02-05 22:18:15 +01:00
2019-04-04 17:38:31 +02:00
implementation 'org.xerial:sqlite-jdbc:3.25.2'
implementation 'org.jetbrains.exposed:exposed:0.12.2'
implementation 'org.mindrot:jbcrypt:0.4'
2019-05-17 22:39:42 +02:00
implementation "de.westermann:KObserve-jvm:$observable_version"
2019-05-30 12:32:40 +02:00
implementation "com.soywiz:klock-jvm:$klockVersion"
implementation "com.soywiz:klock-locale-jvm:$klockVersion"
2019-05-29 12:44:33 +02:00
implementation 'com.github.uchuhimo:konf:master-SNAPSHOT'
2019-05-24 14:29:10 +02:00
implementation 'com.vladsch.flexmark:flexmark-all:0.42.10'
2019-04-04 17:38:31 +02:00
api 'io.github.microutils:kotlin-logging:1.6.23'
2019-02-05 22:18:15 +01:00
api 'ch.qos.logback:logback-classic:1.2.3'
api 'org.fusesource.jansi:jansi:1.8'
}
}
jvmTest {
dependencies {
implementation kotlin('test')
implementation kotlin('test-junit')
}
}
jsMain {
dependencies {
implementation kotlin('stdlib-js')
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serialization_version"
2019-05-17 22:39:42 +02:00
implementation "de.westermann:KObserve-js:$observable_version"
2019-05-30 12:32:40 +02:00
implementation "com.soywiz:klock-js:$klockVersion"
implementation "com.soywiz:klock-locale-js:$klockVersion"
2019-02-05 22:18:15 +01:00
}
}
jsTest {
dependencies {
implementation kotlin('test-js')
}
}
}
}
2019-02-06 17:41:48 +01:00
sass {
2019-02-05 22:18:15 +01:00
main {
srcDir = file("$projectDir/src/jsMain/resources/style")
outDir = file("$buildDir/processedResources/js/main/style")
2019-04-04 17:38:31 +02:00
exclude = "**/*.css"
2019-02-05 22:18:15 +01:00
}
}
def webFolder = new File(project.buildDir, "../web")
task populateWebFolder(dependsOn: [jsMainClasses, sass]) {
doLast {
copy {
2019-06-06 17:24:19 +02:00
from kotlin.targets.js.compilations.main.output
2019-02-05 22:18:15 +01:00
from kotlin.sourceSets.jsMain.resources.srcDirs
2019-06-06 17:24:19 +02:00
kotlin.targets.js.compilations.test.runtimeDependencyFiles.files.each {
2019-02-05 22:18:15 +01:00
if (it.exists() && !it.isDirectory()) {
2019-04-04 17:38:31 +02:00
from zipTree(it.absolutePath).matching {
include '*.js'
exclude '*.meta.js'
}
2019-02-05 22:18:15 +01:00
}
}
into webFolder
}
}
}
jsJar.dependsOn(populateWebFolder)
2019-06-06 17:24:19 +02:00
def mainClassName = 'de.kif.backend.MainKt'
2019-02-06 17:41:48 +01:00
2019-02-05 22:18:15 +01:00
task run(type: JavaExec, dependsOn: [jvmMainClasses, jsJar]) {
2019-02-06 17:41:48 +01:00
main = mainClassName
classpath {
[
kotlin.targets.jvm.compilations.main.output.allOutputs.files,
configurations.jvmRuntimeClasspath,
]
}
2019-02-05 22:18:15 +01:00
args = []
standardInput = System.in
2019-02-05 22:18:15 +01:00
}
clean.doFirst {
delete webFolder
delete ".sessions"
2019-05-29 12:44:33 +02:00
delete "data"
2019-02-05 22:18:15 +01:00
}
2019-02-06 17:41:48 +01:00
2019-06-06 17:24:19 +02:00
jsJar {
from webFolder
}
2019-02-06 17:41:48 +01:00
2019-06-06 17:24:19 +02:00
static String buildTime() {
def format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z")
format.setTimeZone(TimeZone.getTimeZone("UTC"))
return format.format(new Date())
}
task jar(type: ShadowJar, dependsOn: [assemble]) {
//minimize()
from(webFolder) {
2019-02-06 17:41:48 +01:00
into "web"
2019-06-06 17:24:19 +02:00
includeEmptyDirs false
exclude "*.js.map", "*.meta.js", "**/*.scss", "**/_*.css", "**/*.kjsm", "*.MF"
2019-02-06 17:41:48 +01:00
}
2019-06-06 17:24:19 +02:00
from kotlin.targets.jvm.compilations.main.runtimeDependencyFiles
from kotlin.targets.jvm.compilations.main.output
exclude "**/INDEX.LIST", "**/*.SF", "**/*.RSA"
2019-02-06 17:41:48 +01:00
2019-06-06 17:24:19 +02:00
archiveBaseName.set rootProject.name
archiveClassifier.set null
archiveVersion.set null
2019-02-06 17:41:48 +01:00
manifest {
attributes 'Main-Class': mainClassName
2019-06-06 17:24:19 +02:00
attributes "Build-Time": buildTime()
attributes "Build-Version": project.version
attributes "Build-Tools": "gradle-${project.getGradle().getGradleVersion()}, groovy-${GroovySystem.getVersion()}, java-${System.getProperty('java.version')}"
attributes "Build-System": "${System.getProperty("os.name")} '${System.getProperty("os.version")}' (${System.getProperty("os.arch")})"
2019-02-06 17:41:48 +01:00
}
}