From 16939c7b6a3268d7b4b714d2b6a6b58da024ee43 Mon Sep 17 00:00:00 2001 From: Lukas-Heiligenbrunner Date: Tue, 18 Feb 2020 19:22:56 +0100 Subject: [PATCH] added kotlinjs buildscript and test output --- WebServer/build.gradle | 101 +++++++++++++++++++++++++++++++ WebServer/settings.gradle | 1 + WebServer/src/js/Main.kt | 3 + build.gradle | 2 + settings.gradle | 1 + src/resources/wwwroot/index.html | 3 + 6 files changed, 111 insertions(+) create mode 100644 WebServer/build.gradle create mode 100644 WebServer/settings.gradle create mode 100644 WebServer/src/js/Main.kt diff --git a/WebServer/build.gradle b/WebServer/build.gradle new file mode 100644 index 0000000..4c972e5 --- /dev/null +++ b/WebServer/build.gradle @@ -0,0 +1,101 @@ +//plugins { +// id 'org.jetbrains.kotlin.js' version '1.3.70-eap-184' +//} + +//group 'org.example' +version '1.0-SNAPSHOT' + +buildscript { + ext.kotlin_version = '1.3.61' + ext.web_dir = '../src/resources/wwwroot/js/' + repositories { + mavenCentral() + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +apply plugin: 'kotlin2js' + +sourceSets { + main.java.srcDirs = ["src/js/"] + test.java.srcDirs = ["src/js/test"] +} + +compileKotlin2Js { + kotlinOptions.outputFile = "${projectDir}/web/lib/WasteInformationServer.js" + kotlinOptions.moduleKind = "amd" + kotlinOptions.sourceMap = true +} + +compileTestKotlin2Js { + kotlinOptions.moduleKind = "amd" + kotlinOptions.sourceMap = true +} + +repositories { + mavenCentral() + maven { + url "http://dl.bintray.com/kotlin/kotlin-eap-1.1" + } +} + +dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" + testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version" +} + +clean.doFirst() { + delete("${web_dir}") +} + +build.doLast() { + // Copy kotlin.js and kotlin-meta.js from jar into web directory + configurations.compile.each { File file -> + copy { + includeEmptyDirs = false + + from zipTree(file.absolutePath) + into "${projectDir}/${web_dir}/lib" + include { fileTreeElement -> + def path = fileTreeElement.path + path.endsWith(".js") && (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/")) + } + } + } + + // Unpack build contents + // TODO Remove this step when a CDN link is available. + copy { + File artifact = new File("build/libs/${project.name}-${project.version}.jar") + includeEmptyDirs = false + + from zipTree(artifact) + into "${web_dir}" + include { fileTreeElement -> + def path = fileTreeElement.path + !(path.startsWith("META-INF/") || path.startsWith("${project.name}")) + } + } + + // Copy scripts to web directory + copy { + includeEmptyDirs = false + from new File("build/classes/main") + into "${web_dir}/lib" + } + + copy { + includeEmptyDirs = false + from new File("build/classes/test") + into "${web_dir}/lib" + } + + copy { + includeEmptyDirs = false + from new File("build/resources/test") + into "${web_dir}" + } + +} \ No newline at end of file diff --git a/WebServer/settings.gradle b/WebServer/settings.gradle new file mode 100644 index 0000000..8fbafbd --- /dev/null +++ b/WebServer/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'WebServer' \ No newline at end of file diff --git a/WebServer/src/js/Main.kt b/WebServer/src/js/Main.kt new file mode 100644 index 0000000..d414184 --- /dev/null +++ b/WebServer/src/js/Main.kt @@ -0,0 +1,3 @@ +fun main() { + println("success execute main") +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index d7188eb..77fa4bb 100644 --- a/build.gradle +++ b/build.gradle @@ -49,6 +49,8 @@ task createProperties(dependsOn: processResources) { } } +tasks.processResources.dependsOn("WebServer:build") + task myJavadocs(type: Javadoc) { title = "JAVADOC WasteInformationServer" source = sourceSets.main.allJava diff --git a/settings.gradle b/settings.gradle index 5a85d6a..cb567f8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,3 @@ rootProject.name = 'WasteInformationServer' +include 'WebServer' \ No newline at end of file diff --git a/src/resources/wwwroot/index.html b/src/resources/wwwroot/index.html index 22914a9..98b204b 100644 --- a/src/resources/wwwroot/index.html +++ b/src/resources/wwwroot/index.html @@ -31,8 +31,11 @@ + + +