aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/shared.gradle
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-10-08 13:40:04 +0200
committerRobert Jaros <rjaros@finn.pl>2018-10-08 13:40:04 +0200
commit0d3e7c87bf74948f83ce006a1d340b0f3f5e68b0 (patch)
treec86d5d0251da1fa3b208f53d1ca7d634a6cbcc8e /kvision-modules/shared.gradle
parent91ae1d02de111f15608e84193c10ed17bea9fe41 (diff)
downloadkvision-0d3e7c87bf74948f83ce006a1d340b0f3f5e68b0.tar.gz
kvision-0d3e7c87bf74948f83ce006a1d340b0f3f5e68b0.tar.bz2
kvision-0d3e7c87bf74948f83ce006a1d340b0f3f5e68b0.zip
Refactoring to modules
Diffstat (limited to 'kvision-modules/shared.gradle')
-rw-r--r--kvision-modules/shared.gradle65
1 files changed, 65 insertions, 0 deletions
diff --git a/kvision-modules/shared.gradle b/kvision-modules/shared.gradle
new file mode 100644
index 00000000..4ded9c6c
--- /dev/null
+++ b/kvision-modules/shared.gradle
@@ -0,0 +1,65 @@
+apply plugin: 'kotlin-platform-js'
+apply plugin: 'org.jetbrains.kotlin.frontend'
+apply plugin: 'kotlinx-serialization'
+
+kotlinFrontend {
+
+ webpackBundle {
+ bundleName = "main"
+ contentPath = file('src/main/web')
+ mode = production ? "production" : "development"
+ }
+
+ define "PRODUCTION", production
+}
+
+
+dependencies {
+ if (!project.gradle.startParameter.taskNames.contains("generatePomFileForMavenProjectPublication")) {
+ compile project(":kvision-modules:kvision-base")
+ } else {
+ compile rootProject
+ }
+}
+
+task cleanLibs(type: Delete) {
+ delete 'build/js', 'build/libs'
+}
+
+if (project.gradle.startParameter.taskNames.contains("jar")) {
+ compileKotlin2Js.dependsOn 'cleanLibs'
+}
+
+jar {
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+}
+
+compileKotlin2Js {
+ kotlinOptions.metaInfo = true
+ kotlinOptions.outputFile = "$project.buildDir.path/js/${project.name}.js"
+ kotlinOptions.sourceMap = !production
+ kotlinOptions.moduleKind = 'umd'
+}
+
+compileTestKotlin2Js {
+ kotlinOptions.metaInfo = true
+ kotlinOptions.outputFile = "$project.buildDir.path/js-tests/${project.name}-tests.js"
+ kotlinOptions.sourceMap = !production
+ kotlinOptions.moduleKind = 'umd'
+}
+
+task copyResources(type: Copy) {
+ from "src/main/resources"
+ into file(buildDir.path + "/js")
+}
+
+task copyResourcesForTests(type: Copy) {
+ from "src/main/resources"
+ into file(buildDir.path + "/js-tests/")
+}
+
+afterEvaluate {
+ tasks.getByName("webpack-bundle") { dependsOn(copyResources) }
+ tasks.getByName("webpack-run") { dependsOn(copyResources) }
+ tasks.getByName("karma-start") { dependsOn(copyResources, copyResourcesForTests) }
+}