//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}/build/web/WasteInformationServer.js" kotlinOptions.moduleKind = "plain" kotlinOptions.sourceMap = true } compileTestKotlin2Js { kotlinOptions.moduleKind = "plain" 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" } }