From 34bd1db2cca4f8f5efaca5dc778b7c141b86d68d Mon Sep 17 00:00:00 2001 From: Suresh G Date: Wed, 20 Mar 2024 10:40:38 -0700 Subject: [PATCH] chore: fix kotlin gradle DSL deprecations --- .../src/main/kotlin/common/KotlinExtns.kt | 10 +--- .../main/kotlin/plugins/kotlin.mpp.gradle.kts | 50 +++---------------- gradle/libs.versions.toml | 6 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 14 insertions(+), 54 deletions(-) diff --git a/gradle/build-logic/common-plugins/src/main/kotlin/common/KotlinExtns.kt b/gradle/build-logic/common-plugins/src/main/kotlin/common/KotlinExtns.kt index 85b60bd..8173f7a 100644 --- a/gradle/build-logic/common-plugins/src/main/kotlin/common/KotlinExtns.kt +++ b/gradle/build-logic/common-plugins/src/main/kotlin/common/KotlinExtns.kt @@ -15,7 +15,6 @@ import org.gradle.plugin.use.PluginDependency import org.jetbrains.kotlin.gradle.dsl.* import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask -import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest /** Java version properties. */ val Project.javaVersion @@ -165,11 +164,6 @@ fun LanguageSettingsBuilder.configureKotlinLang() { optIn("kotlin.js.ExperimentalJsExport") } -context(Project) -fun KotlinJvmTest.configureKotlinTest() { - configureJavaTest() -} - context(Project) fun Test.configureJavaTest() { useJUnitPlatform() @@ -192,8 +186,8 @@ fun Test.configureJavaTest() { } context(Project) -fun KotlinJsOptions.configureKotlinJs() { - // useEsClasses = true +fun KotlinJsCompilerOptions.configureKotlinJs() { + useEsClasses = true // sourceMap = true // sourceMapEmbedSources = "always" // freeCompilerArgs += listOf("-Xir-per-module") diff --git a/gradle/build-logic/common-plugins/src/main/kotlin/plugins/kotlin.mpp.gradle.kts b/gradle/build-logic/common-plugins/src/main/kotlin/plugins/kotlin.mpp.gradle.kts index 5598c39..799c2cd 100644 --- a/gradle/build-logic/common-plugins/src/main/kotlin/plugins/kotlin.mpp.gradle.kts +++ b/gradle/build-logic/common-plugins/src/main/kotlin/plugins/kotlin.mpp.gradle.kts @@ -6,7 +6,6 @@ import org.jetbrains.kotlin.gradle.dsl.* import org.jetbrains.kotlin.gradle.dsl.jvm.JvmTargetValidationMode import org.jetbrains.kotlin.gradle.targets.js.nodejs.* import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask -import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig import org.jetbrains.kotlin.gradle.targets.js.yarn.* import tasks.BuildConfig @@ -27,33 +26,25 @@ val kotlinMultiplatform = extensions.getByType() kotlinMultiplatform.apply { applyDefaultHierarchyTemplate() - jvmToolchain { configureJvmToolchain() } targets.all { - // Configure all compilations of all targets - compilations.all { compilerOptions.configure { configureKotlinCommon() } } + compilations.all { + compileTaskProvider.configure { compilerOptions { configureKotlinCommon() } } + } } jvm { withJava() compilations.all { compileJavaTaskProvider?.configure { configureJavac() } - compilerOptions.configure { configureKotlinJvm() } + compileTaskProvider.configure { compilerOptions { configureKotlinJvm() } } } + // ./gradlew jvmRun + mainRun { mainClass = libs.versions.app.mainclass.get() } // val test by testRuns.existing - testRuns.configureEach { executionTask.configure { configureKotlinTest() } } - attributes.attribute(mppTargetAttr, "jvm") - } - - jvm("desktop") { - compilations.all { - compileJavaTaskProvider?.configure { configureJavac() } - compilerOptions.configure { configureKotlinJvm() } - } - testRuns.configureEach { executionTask.configure { configureKotlinTest() } } - attributes.attribute(mppTargetAttr, "desktop") + testRuns.configureEach { executionTask.configure { configureJavaTest() } } } js(IR) { @@ -78,30 +69,6 @@ kotlinMultiplatform.apply { } } - // Disable wasm by default as some of the common dependencies are not compatible with wasm. - if (project.hasProperty("experimental")) { - - wasmJs { - binaries.executable() - browser { - commonWebpackConfig( - Action { - devServer = - (devServer ?: KotlinWebpackConfig.DevServer()).copy( - open = mapOf("app" to mapOf("name" to "google chrome"))) - }) - } - } - - // Use custom allocator for native targets - macosX64("native") { - binaries.executable() - compilations.configureEach { - compilerOptions.configure { freeCompilerArgs.add("-Xallocator=custom") } - } - } - } - @Suppress("UNUSED_VARIABLE") this.sourceSets { all { @@ -186,7 +153,6 @@ tasks { // Register buildConfig task only for common module val buildConfig by registering(BuildConfig::class) { classFqName = "BuildConfig" } kotlinMultiplatform.sourceSets.named("commonMain") { kotlin.srcDirs(buildConfig) } - maybeRegister("prepareKotlinIdeaImport") { dependsOn(buildConfig) } } // configure jvm target for ksp @@ -195,7 +161,7 @@ tasks { jvmTargetValidationMode = JvmTargetValidationMode.WARNING } - withType().configureEach { kotlinOptions { configureKotlinJs() } } + withType().configureEach { compilerOptions { configureKotlinJs() } } withType().configureEach { configureKotlinNpm() } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 857bb76..22aaa48 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,12 +1,12 @@ [versions] java = "23" -kotlin = "2.0.0-Beta4" +kotlin = "2.0.0-Beta5" kotlin-ksp = "2.0.0-Beta4-1.0.19" kotlin-jvmtarget = "21" kotlin-dsl-jvmtarget = "21" kotlin-api-version = "1.9" kotlin-lang-version = "2.0" -gradle = "8.7-rc-3" +gradle = "8.7-rc-4" java-vendor = "GraalVM Community" java-jvmArguments = "--enable-preview" java-addModules = "jdk.incubator.vector" @@ -28,7 +28,7 @@ kotlinx-coroutines = "1.8.1-Beta" kotlinx-datetime = "0.6.0-RC.2" kotlinx-serialization = "1.6.3" kotlinx-collections-immutable = "0.3.7" -kotlinx-lincheck = "2.27" +kotlinx-lincheck = "2.28" kotlinx-benchmark = "0.4.8" kotlinx-reflect-lite = "1.1.0" zip-prefixer = "0.3.1" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fc62ce6..70fe720 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-rc-3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-rc-4-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME