From 3220ff11e6ae53718b021db873e97036ce97b90d Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Mon, 18 Jan 2021 18:22:41 +0300 Subject: [PATCH 1/2] Move & rename compile-js.gradle and compile-jvm.gradle to kotlin-js-conventions.gradle.kts and kotlin-jvm-conventions.gradle.kts, but do not changes them (yet) to preserve history --- .../src/main/kotlin/kotlin-js-conventions.gradle.kts | 0 .../src/main/kotlin/kotlin-jvm-conventions.gradle.kts | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename gradle/compile-js.gradle => buildSrc/src/main/kotlin/kotlin-js-conventions.gradle.kts (100%) rename gradle/compile-jvm.gradle => buildSrc/src/main/kotlin/kotlin-jvm-conventions.gradle.kts (94%) diff --git a/gradle/compile-js.gradle b/buildSrc/src/main/kotlin/kotlin-js-conventions.gradle.kts similarity index 100% rename from gradle/compile-js.gradle rename to buildSrc/src/main/kotlin/kotlin-js-conventions.gradle.kts diff --git a/gradle/compile-jvm.gradle b/buildSrc/src/main/kotlin/kotlin-jvm-conventions.gradle.kts similarity index 94% rename from gradle/compile-jvm.gradle rename to buildSrc/src/main/kotlin/kotlin-jvm-conventions.gradle.kts index bd2ae14775..d016d8613f 100644 --- a/gradle/compile-jvm.gradle +++ b/buildSrc/src/main/kotlin/kotlin-jvm-conventions.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ // Platform-specific configuration to compile JVM modules From e53840146793b3ba54f3b9c29eebc75631430011 Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Mon, 18 Jan 2021 18:26:35 +0300 Subject: [PATCH 2/2] Kotlin DSL - Kotlin conventions (JVM & JS) --- build.gradle | 4 +- .../kotlin/kotlin-js-conventions.gradle.kts | 26 ++++++++----- .../kotlin/kotlin-jvm-conventions.gradle.kts | 38 +++++++++++-------- integration-testing/build.gradle | 10 +++-- 4 files changed, 47 insertions(+), 31 deletions(-) diff --git a/build.gradle b/build.gradle index 866ee135b8..8ba7a6ae7e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ import org.jetbrains.kotlin.konan.target.HostManager import org.gradle.util.VersionNumber @@ -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 index 55c81fe56e..c1897ca749 100644 --- a/buildSrc/src/main/kotlin/kotlin-js-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/kotlin-js-conventions.gradle.kts @@ -1,29 +1,37 @@ /* - * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2021 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' +import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile + +plugins { + kotlin("js") +} dependencies { - testImplementation "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version" + testImplementation(kotlin("test-js")) } kotlin { js(LEGACY) { - moduleName = project.name - "-js" + moduleName = project.name.removeSuffix("-js") } sourceSets { - main.kotlin.srcDirs = ['src'] - test.kotlin.srcDirs = ['test'] - main.resources.srcDirs = ['resources'] - test.resources.srcDirs = ['test-resources'] + main { + kotlin.srcDirs("src") + resources.srcDirs("resources") + } + test { + kotlin.srcDirs("test") + resources.srcDirs("test-resources") + } } } -tasks.withType(compileKotlinJs.getClass()) { +tasks.withType { kotlinOptions { moduleKind = "umd" sourceMap = true diff --git a/buildSrc/src/main/kotlin/kotlin-jvm-conventions.gradle.kts b/buildSrc/src/main/kotlin/kotlin-jvm-conventions.gradle.kts index d016d8613f..89007718c8 100644 --- a/buildSrc/src/main/kotlin/kotlin-jvm-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/kotlin-jvm-conventions.gradle.kts @@ -4,37 +4,43 @@ // Platform-specific configuration to compile JVM modules -apply plugin: 'org.jetbrains.kotlin.jvm' +import org.gradle.api.* -sourceCompatibility = 1.6 -targetCompatibility = 1.6 +plugins { + kotlin("jvm") +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_6 + targetCompatibility = JavaVersion.VERSION_1_6 +} -if (rootProject.ext.jvm_ir_enabled) { - kotlin.target.compilations.all { +if (rootProject.extra.get("jvm_ir_enabled") as Boolean) { + kotlin.target.compilations.configureEach { kotlinOptions.useIR = true } } dependencies { - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testCompile(kotlin("test")) // 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" + testCompile(kotlin("reflect")) + testCompile(kotlin("stdlib-jdk7")) + testCompile(kotlin("test-junit")) + testCompile("junit:junit:${version("junit")}") } -compileKotlin { +tasks.compileKotlin { kotlinOptions { - freeCompilerArgs += ['-Xexplicit-api=strict'] + freeCompilerArgs += listOf("-Xexplicit-api=strict") } } -tasks.withType(Test) { +tasks.withType { testLogging { showStandardStreams = true - events "passed", "failed" + events("passed", "failed") } - def stressTest = project.properties['stressTest'] - if (stressTest != null) systemProperties['stressTest'] = stressTest + val stressTest = project.properties["stressTest"] + if (stressTest != null) systemProperties["stressTest"] = stressTest } diff --git a/integration-testing/build.gradle b/integration-testing/build.gradle index b1cbc08f76..c5a551a05f 100644 --- a/integration-testing/build.gradle +++ b/integration-testing/build.gradle @@ -1,10 +1,12 @@ -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. + * Copyright 2016-2021 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") +import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType + +plugins { + id("kotlin-jvm-conventions") +} repositories { mavenLocal()