Skip to content

Commit

Permalink
Update to Kotlin 2.0 + apply default hierarchy template (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
serras authored Dec 17, 2024
1 parent 97ba7b5 commit a9a440d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

group = property("projects.group").toString()

Expand All @@ -27,8 +26,6 @@ configure<JavaPluginExtension> {
}
}

val enable_wasm = (project.rootProject.properties["enable_wasm"] as? String).toBoolean()

if (isKotlinMultiplatform) {
configure<KotlinMultiplatformExtension> {
jvm {
Expand All @@ -40,8 +37,11 @@ if (isKotlinMultiplatform) {
nodejs()
}

if (enable_wasm) {
@OptIn(ExperimentalWasmDsl::class) wasmJs()
@OptIn(org.jetbrains.kotlin.gradle.ExperimentalWasmDsl::class)
wasmJs {
browser()
nodejs()
d8()
}

// Native: https://kotlinlang.org/docs/native-target-support.html
Expand All @@ -68,43 +68,20 @@ if (isKotlinMultiplatform) {
// iosArm32() // deprecated as of 1.8.20
// watchosX86()

applyDefaultHierarchyTemplate()

sourceSets {
val commonMain by getting
val commonTest by getting

val nonJvmMain by creating { dependsOn(commonMain) }
val nonJvmTest by creating { dependsOn(commonTest) }

val nativeMain by creating { dependsOn(nonJvmMain) }
val nativeTest by creating { dependsOn(nonJvmTest) }

// Native
// -- Tier 1 --
val linuxX64Main by getting { dependsOn(nativeMain) }
val macosX64Main by getting { dependsOn(nativeMain) }
val macosArm64Main by getting { dependsOn(nativeMain) }
val iosSimulatorArm64Main by getting { dependsOn(nativeMain) }
val iosX64Main by getting { dependsOn(nativeMain) }
// -- Tier 2 --
val linuxArm64Main by getting { dependsOn(nativeMain) }
val watchosSimulatorArm64Main by getting { dependsOn(nativeMain) }
val watchosX64Main by getting { dependsOn(nativeMain) }
val watchosArm32Main by getting { dependsOn(nativeMain) }
val watchosArm64Main by getting { dependsOn(nativeMain) }
val tvosSimulatorArm64Main by getting { dependsOn(nativeMain) }
val tvosX64Main by getting { dependsOn(nativeMain) }
val tvosArm64Main by getting { dependsOn(nativeMain) }
val iosArm64Main by getting { dependsOn(nativeMain) }
// -- Tier 3 --
val mingwX64Main by getting { dependsOn(nativeMain) }

val jsMain by getting { dependsOn(nonJvmMain) }
val jsTest by getting { dependsOn(nonJvmTest) }

if (enable_wasm) {
val wasmJsMain by getting { dependsOn(nonJvmMain) }
val wasmJsTest by getting { dependsOn(nonJvmTest) }
}
val nonJvmMain by creating { dependsOn(commonMain.get()) }
val nonJvmTest by creating { dependsOn(commonTest.get()) }

nativeMain.get().dependsOn(nonJvmMain)
nativeTest.get().dependsOn(nonJvmTest)

jsMain.get().dependsOn(nonJvmMain)
jsTest.get().dependsOn(nonJvmTest)

wasmJsMain.get().dependsOn(nonJvmMain)
wasmJsTest.get().dependsOn(nonJvmTest)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.gradle.api.Project
import org.gradle.api.XmlProvider
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.configurationcache.extensions.capitalized
import org.gradle.kotlin.dsl.getByName

internal fun Project.publishPlatformArtifactsInRootModule() {
Expand Down Expand Up @@ -58,7 +57,9 @@ internal fun Project.publishPlatformArtifactsInRootModule() {
tasks
.matching { it.name == "generatePomFileForKotlinMultiplatformPublication" }
.configureEach {
dependsOn("generatePomFileFor${platformPublication.name.capitalized()}Publication")
dependsOn(
"generatePomFileFor${platformPublication.name.toString().replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }}Publication"
)
}
}
}
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[versions]
android = "8.3.2"
arrow = "1.2.4"
android = "8.7.3"
arrow = "2.0.0"
arrowGradleConfig = "0.11.0"
coroutines = "1.8.0"
dokka = "1.9.20"
coroutines = "1.9.0"
dokka = "2.0.0"
gradlePublish = "0.21.0"
javierscSemverGradlePlugin = "0.5.1"
kotlin = "1.9.23"
kotlin = "2.0.20"
nexusPublish = "1.3.0"
spotless = "6.25.0"

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit a9a440d

Please sign in to comment.