diff --git a/build.gradle.kts b/build.gradle.kts index 616260d..e9a7bc3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,6 +25,7 @@ kotlin.explicitApiWarning() dependencies { api(libs.kotlin.gradle) + api("org.gradle.toolchains:foojay-resolver:0.7.0") implementation(libs.binary.compatibility.validator) implementation(libs.changelog.gradle) implementation(libs.dokka.gradle) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c6ba410..a01b656 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] -tools = "0.15.0-kotlin-1.9.20-Beta2" -kotlin = "1.9.20-Beta2" +tools = "0.15.0-kotlin-1.9.20-RC" +kotlin = "1.9.20-RC" # https://github.com/Kotlin/kotlinx-atomicfu atomicfu = "0.22.0" # https://github.com/Kotlin/binary-compatibility-validator diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index db9a6b8..e411586 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt b/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt index 3e04ae3..db82c59 100644 --- a/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt +++ b/src/main/kotlin/space/kscience/gradle/KScienceExtension.kt @@ -1,6 +1,5 @@ package space.kscience.gradle -import org.gradle.api.Action import org.gradle.api.Project import org.gradle.api.file.DuplicatesStrategy import org.gradle.api.plugins.ApplicationPlugin @@ -17,7 +16,10 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget -import org.jetbrains.kotlin.gradle.targets.js.dsl.* +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl +import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBrowserDsl +import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl +import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinWasmJsTargetDsl import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlinx.jupyter.api.plugin.tasks.JupyterApiResourcesTask @@ -179,13 +181,6 @@ public open class KScienceExtension(public val project: Project) { } } - project.pluginManager.withPlugin("org.jetbrains.kotlin.js") { - project.configure { - sourceSets.getByName(sourceSet ?: "test") { - dependencies(dependencyBlock) - } - } - } project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { project.configure { @@ -373,7 +368,7 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro project.configure { jvm { compilations.all { - compilerOptions { + compilerOptions.configure { freeCompilerArgs.addAll(defaultKotlinJvmArgs) } } @@ -421,8 +416,11 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro } } + /** + * Add Wasm/Js target + */ @OptIn(ExperimentalWasmDsl::class) - public fun wasm(block: KotlinWasmTargetDsl.() -> Unit = {}) { + public fun wasm(block: KotlinWasmJsTargetDsl.() -> Unit = {}) { // if (project.requestPropertyOrNull("kscience.wasm.disabled") == "true") { // project.logger.warn("Wasm target is disabled with 'kscience.wasm.disabled' property") // return @@ -434,7 +432,7 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro browser { testTask { useKarma { - this.webpackConfig.experiments.add("topLevelAwait") + webpackConfig.experiments.add("topLevelAwait") useChromeHeadlessWasmGc() useConfigDirectory(project.projectDir.resolve("karma.config.d").resolve("wasm")) } @@ -469,14 +467,14 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro browserConfig: KotlinJsBrowserDsl.() -> Unit = {}, ) { js { - binaries.executable() browser { - webpackTask(Action { + webpackTask { mainOutputFileName.set(bundleName) - }) + } browserConfig() } jsConfig() + binaries.executable() } jvm { val processResourcesTaskName = diff --git a/src/main/kotlin/space/kscience/gradle/KScienceMPPlugin.kt b/src/main/kotlin/space/kscience/gradle/KScienceMPPlugin.kt index cb02302..72858c1 100644 --- a/src/main/kotlin/space/kscience/gradle/KScienceMPPlugin.kt +++ b/src/main/kotlin/space/kscience/gradle/KScienceMPPlugin.kt @@ -10,6 +10,7 @@ import org.jetbrains.dokka.gradle.DokkaPlugin import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin import space.kscience.gradle.internal.applySettings +import space.kscience.gradle.internal.defaultKotlinCommonArgs public open class KScienceMPPlugin : Plugin { override fun apply(project: Project): Unit = project.run { @@ -23,23 +24,29 @@ public open class KScienceMPPlugin : Plugin { registerKScienceExtension(::KScienceMppExtension) configure { - sourceSets { - getByName("commonMain"){ + getByName("commonMain") { dependencies { api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}")) } } - getByName("commonTest"){ + getByName("commonTest") { dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) } } + all { + languageSettings.applySettings() + } } - sourceSets.all { - languageSettings.applySettings() + targets.all { + compilations.all { + kotlinOptions{ + freeCompilerArgs += defaultKotlinCommonArgs + } + } } if (explicitApi == null) explicitApiWarning() diff --git a/src/main/kotlin/space/kscience/gradle/internal/common.kt b/src/main/kotlin/space/kscience/gradle/internal/common.kt index 096e0a2..1008006 100644 --- a/src/main/kotlin/space/kscience/gradle/internal/common.kt +++ b/src/main/kotlin/space/kscience/gradle/internal/common.kt @@ -13,6 +13,10 @@ internal val defaultKotlinJvmArgs: List = listOf( /* "-Xjdk-release=${KScienceVersions.JVM_TARGET}"*/ ) +internal val defaultKotlinCommonArgs: List = listOf( + "-Xexpect-actual-classes" +) + internal fun resolveKotlinVersion(): KotlinVersion { val (major, minor, patch) = KScienceVersions.kotlinVersion.split(".", "-") return KotlinVersion(major.toInt(), minor.toInt(), patch.toInt())