added kotlinjs buildscript and test output

This commit is contained in:
Lukas-Heiligenbrunner 2020-02-18 19:22:56 +01:00
parent fbc53b97f5
commit 16939c7b6a
6 changed files with 111 additions and 0 deletions

101
WebServer/build.gradle Normal file
View File

@ -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}"
}
}

View File

@ -0,0 +1 @@
rootProject.name = 'WebServer'

3
WebServer/src/js/Main.kt Normal file
View File

@ -0,0 +1,3 @@
fun main() {
println("success execute main")
}

View File

@ -49,6 +49,8 @@ task createProperties(dependsOn: processResources) {
}
}
tasks.processResources.dependsOn("WebServer:build")
task myJavadocs(type: Javadoc) {
title = "JAVADOC WasteInformationServer"
source = sourceSets.main.allJava

View File

@ -1,2 +1,3 @@
rootProject.name = 'WasteInformationServer'
include 'WebServer'

View File

@ -31,8 +31,11 @@
<link rel="manifest" href="/manifest.json">
<link rel="icon" type="image/png" href="/favicon.png">
</head>
<body>
<script type="text/javascript" src="js/lib/kotlin.js"></script>
<script type="text/javascript" src="js/WasteInformationServer.js"></script>
<div class="container">
<div class="d-flex justify-content-center h-100">
<div class="card">