diff --git a/build.gradle b/build.gradle index 866ee135b8..278c60d710 100644 --- a/build.gradle +++ b/build.gradle @@ -183,7 +183,7 @@ allprojects { configure(subprojects.findAll { !sourceless.contains(it.name) && it.name != coreModule }) { evaluationDependsOn(":$coreModule") def platform = PlatformKt.platformOf(it) - apply from: rootProject.file("gradle/compile-${platform}.gradle") + apply plugin: "kotlin-${platform}-conventions" dependencies { // See comment below for rationale, it will be replaced with "project" dependency compile project(":$coreModule") diff --git a/buildSrc/src/main/kotlin/kotlin-js-conventions.gradle.kts b/buildSrc/src/main/kotlin/kotlin-js-conventions.gradle.kts new file mode 100644 index 0000000000..9ba70410c2 --- /dev/null +++ b/buildSrc/src/main/kotlin/kotlin-js-conventions.gradle.kts @@ -0,0 +1,40 @@ +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// Platform-specific configuration to compile JS modules + +import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile + +plugins { + kotlin("js") +} + +dependencies { + testImplementation(kotlin("test-js")) +} + +kotlin { + js(LEGACY) { + moduleName = project.name.removeSuffix("-js") + } + + sourceSets { + main { + kotlin.srcDirs("src") + resources.srcDirs("resources") + } + test { + kotlin.srcDirs("test") + resources.srcDirs("test-resources") + } + } +} + +tasks.withType { + kotlinOptions { + moduleKind = "umd" + sourceMap = true + metaInfo = true + } +} diff --git a/buildSrc/src/main/kotlin/kotlin-jvm-conventions.gradle.kts b/buildSrc/src/main/kotlin/kotlin-jvm-conventions.gradle.kts new file mode 100644 index 0000000000..3a0b8ed892 --- /dev/null +++ b/buildSrc/src/main/kotlin/kotlin-jvm-conventions.gradle.kts @@ -0,0 +1,46 @@ +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// Platform-specific configuration to compile JVM modules + +import org.gradle.api.* + +plugins { + kotlin("jvm") +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_6 + targetCompatibility = JavaVersion.VERSION_1_6 +} + +if (rootProject.extra.get("jvm_ir_enabled") as Boolean) { + kotlin.target.compilations.configureEach { + kotlinOptions.useIR = true + } +} + +dependencies { + testCompile(kotlin("test")) + // Workaround to make addSuppressed work in tests + testCompile(kotlin("reflect")) + testCompile(kotlin("stdlib-jdk7")) + testCompile(kotlin("test-junit")) + testCompile("junit:junit:${version("junit")}") +} + +tasks.compileKotlin { + kotlinOptions { + freeCompilerArgs += listOf("-Xexplicit-api=strict") + } +} + +tasks.withType { + testLogging { + showStandardStreams = true + events("passed", "failed") + } + val stressTest = project.properties["stressTest"] + if (stressTest != null) systemProperties["stressTest"] = stressTest +} diff --git a/gradle/compile-js.gradle b/gradle/compile-js.gradle deleted file mode 100644 index 55c81fe56e..0000000000 --- a/gradle/compile-js.gradle +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -// Platform-specific configuration to compile JS modules - -apply plugin: 'org.jetbrains.kotlin.js' - -dependencies { - testImplementation "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version" -} - -kotlin { - js(LEGACY) { - moduleName = project.name - "-js" - } - - sourceSets { - main.kotlin.srcDirs = ['src'] - test.kotlin.srcDirs = ['test'] - main.resources.srcDirs = ['resources'] - test.resources.srcDirs = ['test-resources'] - } -} - -tasks.withType(compileKotlinJs.getClass()) { - kotlinOptions { - moduleKind = "umd" - sourceMap = true - metaInfo = true - } -} diff --git a/gradle/compile-jvm.gradle b/gradle/compile-jvm.gradle deleted file mode 100644 index bd2ae14775..0000000000 --- a/gradle/compile-jvm.gradle +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -// Platform-specific configuration to compile JVM modules - -apply plugin: 'org.jetbrains.kotlin.jvm' - -sourceCompatibility = 1.6 -targetCompatibility = 1.6 - -if (rootProject.ext.jvm_ir_enabled) { - kotlin.target.compilations.all { - kotlinOptions.useIR = true - } -} - -dependencies { - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - // Workaround to make addSuppressed work in tests - testCompile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" - testCompile "junit:junit:$junit_version" -} - -compileKotlin { - kotlinOptions { - freeCompilerArgs += ['-Xexplicit-api=strict'] - } -} - -tasks.withType(Test) { - testLogging { - showStandardStreams = true - events "passed", "failed" - } - def stressTest = project.properties['stressTest'] - if (stressTest != null) systemProperties['stressTest'] = stressTest -} diff --git a/integration-testing/build.gradle b/integration-testing/build.gradle index b1cbc08f76..7a5b013500 100644 --- a/integration-testing/build.gradle +++ b/integration-testing/build.gradle @@ -4,7 +4,9 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -apply from: rootProject.file("gradle/compile-jvm.gradle") +plugins { + id("kotlin-jvm-conventions") +} repositories { mavenLocal()