diff --git a/build.gradle b/build.gradle index 08a241a411..2908205cef 100644 --- a/build.gradle +++ b/build.gradle @@ -239,7 +239,7 @@ configure(subprojects.findAll { it.name != coreModule && it.name != rootModule } } // Redefine source sets because we are not using 'kotlin/main/fqn' folder convention -configure(subprojects.findAll { !sourceless.contains(it.name) && it.name != "benchmarks" && it.name != coreModule }) { +configure(subprojects.findAll { !sourceless.contains(it.name) && it.name != "benchmarks" && it.name != 'example-frontend-js' && it.name != coreModule }) { sourceSets { main.kotlin.srcDirs = ['src'] test.kotlin.srcDirs = ['test'] diff --git a/gradle/compile-js.gradle b/gradle/compile-js.gradle index d0697cfd3a..77de787fb8 100644 --- a/gradle/compile-js.gradle +++ b/gradle/compile-js.gradle @@ -4,14 +4,21 @@ // Platform-specific configuration to compile JS modules -apply plugin: 'kotlin2js' +apply plugin: 'org.jetbrains.kotlin.js' + +kotlin.sourceSets { + main.kotlin.srcDirs = ['src'] + test.kotlin.srcDirs = ['test'] + main.resources.srcDirs = ['resources'] + test.resources.srcDirs = ['test-resources'] +} dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version" } -tasks.withType(compileKotlin2Js.getClass()) { +tasks.withType(compileKotlinJs.getClass()) { kotlinOptions { moduleKind = "umd" sourceMap = true @@ -19,7 +26,7 @@ tasks.withType(compileKotlin2Js.getClass()) { } } -compileKotlin2Js { +compileKotlinJs { kotlinOptions { // drop -js suffix from outputFile def baseName = project.name - "-js" diff --git a/js/example-frontend-js/build.gradle b/js/example-frontend-js/build.gradle index dc4dfd2d9a..f81efdd2f9 100644 --- a/js/example-frontend-js/build.gradle +++ b/js/example-frontend-js/build.gradle @@ -5,36 +5,19 @@ apply plugin: 'kotlin-dce-js' apply from: rootProject.file('gradle/node-js.gradle') -// Workaround resolving new Gradle metadata with kotlin2js -// TODO: Remove once KT-37188 is fixed -try { - def jsCompilerType = Class.forName("org.jetbrains.kotlin.gradle.targets.js.JsCompilerType") - def jsCompilerAttr = Attribute.of("org.jetbrains.kotlin.js.compiler", jsCompilerType) - project.dependencies.attributesSchema.attribute(jsCompilerAttr) - configurations { - matching { - it.name.endsWith("Classpath") - }.forEach { - it.attributes.attribute(jsCompilerAttr, jsCompilerType.legacy) - } - } -} catch (java.lang.ClassNotFoundException e) { - // org.jetbrains.kotlin.gradle.targets.js.JsCompilerType is missing in 1.3.x - // But 1.3.x doesn't generate Gradle metadata, so this workaround is not needed -} - dependencies { compile "org.jetbrains.kotlinx:kotlinx-html-js:$html_version" } -compileKotlin2Js { +compileKotlinJs { kotlinOptions { main = "call" } } -task bundle(type: NpmTask, dependsOn: [npmInstall, runDceKotlinJs]) { +task bundle(type: NpmTask, dependsOn: [npmInstall, build]) { inputs.files(fileTree("$buildDir/kotlin-js-min/main")) + inputs.files(fileTree("$buildDir/kotlin-js-min/legacy/main")) inputs.files(fileTree(file("src/main/web"))) inputs.file("npm/webpack.config.js") outputs.dir("$buildDir/dist") @@ -44,11 +27,3 @@ task bundle(type: NpmTask, dependsOn: [npmInstall, runDceKotlinJs]) { task start(type: NpmTask, dependsOn: bundle) { args = ["run", "start"] } - -// we have not tests but kotlin-dce-js still tries to work with them and crashed. -// todo: Remove when KT-22028 is fixed -afterEvaluate { - if (tasks.findByName('unpackDependenciesTestKotlinJs')) { - tasks.unpackDependenciesTestKotlinJs.enabled = false - } -} diff --git a/js/example-frontend-js/npm/webpack.config.js b/js/example-frontend-js/npm/webpack.config.js index a208d047b3..8428c55741 100644 --- a/js/example-frontend-js/npm/webpack.config.js +++ b/js/example-frontend-js/npm/webpack.config.js @@ -38,6 +38,7 @@ module.exports = { resolve: { modules: [ path.resolve(__dirname, "kotlin-js-min/main"), + path.resolve(__dirname, "kotlin-js-min/legacy/main"), path.resolve(__dirname, "../src/main/web/") ] },