portal/build.gradle
2019-02-06 17:41:48 +01:00

162 lines
4.2 KiB
Groovy

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
plugins {
id 'kotlin-multiplatform' version '1.3.20'
id 'kotlinx-serialization' version '1.3.20'
id "org.kravemir.gradle.sass" version "1.2.2"
id "com.github.johnrengelman.shadow" version "4.0.4"
}
group "de.kif"
version "0.1.0"
repositories {
jcenter()
maven { url "http://dl.bintray.com/kotlin/ktor" }
maven { url "https://kotlin.bintray.com/kotlinx" }
mavenCentral()
}
def ktor_version = '1.1.2'
def serialization_version = '0.10.0'
kotlin {
jvm()
js() {
compilations.all {
kotlinOptions {
moduleKind = "umd"
sourceMap = true
metaInfo = true
}
}
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
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-websockets:$ktor_version"
implementation "io.ktor:ktor-html-builder:$ktor_version"
api 'io.github.microutils:kotlin-logging:1.5.4'
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"
implementation "de.westermann:KObserve-js:0.8.0"
}
}
jsTest {
dependencies {
implementation kotlin('test-js')
}
}
}
}
sass {
main {
srcDir = file("$projectDir/src/jsMain/resources/style")
outDir = file("$buildDir/processedResources/js/main/style")
}
}
def webFolder = new File(project.buildDir, "../web")
def jsCompilations = kotlin.targets.js.compilations
task populateWebFolder(dependsOn: [jsMainClasses, sass]) {
doLast {
copy {
from jsCompilations.main.output
from kotlin.sourceSets.jsMain.resources.srcDirs
jsCompilations.test.runtimeDependencyFiles.each {
if (it.exists() && !it.isDirectory()) {
from zipTree(it.absolutePath).matching { include '*.js' }
}
}
into webFolder
}
}
}
jsJar.dependsOn(populateWebFolder)
def mainClassName = 'de.kif.backend.Main'
task run(type: JavaExec, dependsOn: [jvmMainClasses, jsJar]) {
main = mainClassName
classpath {
[
kotlin.targets.jvm.compilations.main.output.allOutputs.files,
configurations.jvmRuntimeClasspath,
]
}
args = []
}
clean.doFirst {
delete webFolder
}
task jar(type: ShadowJar, dependsOn: [jvmMainClasses, jsMainClasses, sass]) {
from kotlin.targets.jvm.compilations.main.output
from (kotlin.targets.js.compilations.main.output) {
into "web"
}
from (kotlin.sourceSets.jsMain.resources.srcDirs) {
into "web"
}
configurations = [kotlin.targets.jvm.compilations.main.compileDependencyFiles]
baseName = rootProject.name
classifier = null
version = null
manifest {
attributes 'Main-Class': mainClassName
}
}