diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 113372ff..f05ba5f4 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -7,7 +7,7 @@ runs: - uses: "actions/setup-java@v4" with: distribution: "temurin" - java-version: 23 + java-version: 21 - uses: "gradle/actions/setup-gradle@v4" with: build-scan-publish: true diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 8d5d12f4..a3ea271b 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -44,7 +44,7 @@ jobs: - uses: "actions/setup-java@v4" with: distribution: "temurin" - java-version: 23 + java-version: 21 - uses: "gradle/actions/dependency-submission@v4" with: build-scan-publish: true diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index ff98f5d3..0bd89fb1 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -6,6 +6,8 @@ repositories { google() } +kotlin { jvmToolchain(21) } + dependencies { pluginImplementation(libs.plugins.android.application) pluginImplementation(libs.plugins.android.library) diff --git a/buildSrc/src/main/kotlin/library-conventions.gradle.kts b/buildSrc/src/main/kotlin/library-conventions.gradle.kts index 4472e6c4..f26a3c87 100644 --- a/buildSrc/src/main/kotlin/library-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/library-conventions.gradle.kts @@ -11,6 +11,8 @@ group = "dev.sargunv.maplibre-compose" kotlin { explicitApi() + jvmToolchain(properties["jvmToolchain"]!!.toString().toInt()) + compilerOptions { allWarningsAsErrors = true freeCompilerArgs.addAll("-Xexpect-actual-classes", "-Xconsistent-data-class-copy-visibility") diff --git a/buildSrc/src/main/kotlin/util.kt b/buildSrc/src/main/kotlin/util.kt new file mode 100644 index 00000000..5afd0df2 --- /dev/null +++ b/buildSrc/src/main/kotlin/util.kt @@ -0,0 +1,7 @@ +import org.gradle.api.Project +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + +fun Project.getJvmTarget(): JvmTarget { + val target = properties["jvmTarget"]!!.toString().toInt() + return JvmTarget.valueOf("JVM_$target") +} diff --git a/demo-app/build.gradle.kts b/demo-app/build.gradle.kts index 458a77e9..a773bca5 100644 --- a/demo-app/build.gradle.kts +++ b/demo-app/build.gradle.kts @@ -3,7 +3,6 @@ import org.jetbrains.compose.ExperimentalComposeLibrary import org.jetbrains.compose.desktop.application.dsl.TargetFormat import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi -import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree plugins { @@ -40,19 +39,13 @@ android { kotlin { androidTarget { - compilerOptions { - jvmTarget.set(JvmTarget.valueOf(project.properties["jvmTarget"]!!.toString())) - } + compilerOptions { jvmTarget = project.getJvmTarget() } instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) } iosArm64() iosSimulatorArm64() iosX64() - jvm("desktop") { - compilerOptions { - jvmTarget.set(JvmTarget.valueOf(project.properties["jvmTarget"]!!.toString())) - } - } + jvm("desktop") { compilerOptions { jvmTarget = project.getJvmTarget() } } js(IR) { browser { commonWebpackConfig { outputFileName = "app.js" } } binaries.executable() diff --git a/gradle.properties b/gradle.properties index 06fae1fe..10e9a951 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,8 @@ androidMinSdk=23 androidCompileSdk=35 androidTargetSdk=35 iosDeploymentTarget=12.0 -jvmTarget=JVM_11 +jvmToolchain=21 +jvmTarget=11 kotlin.code.style=official kotlin.daemon.jvmargs=-Xmx2048M kotlin.incremental.wasm=true diff --git a/lib/maplibre-compose-expressions/build.gradle.kts b/lib/maplibre-compose-expressions/build.gradle.kts index 5eb29626..c3b21ee7 100644 --- a/lib/maplibre-compose-expressions/build.gradle.kts +++ b/lib/maplibre-compose-expressions/build.gradle.kts @@ -2,7 +2,6 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl -import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree plugins { @@ -27,20 +26,14 @@ mavenPublishing { kotlin { androidTarget { - compilerOptions { - jvmTarget.set(JvmTarget.valueOf(project.properties["jvmTarget"]!!.toString())) - } + compilerOptions { jvmTarget = project.getJvmTarget() } instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishLibraryVariants("release", "debug") } iosArm64() iosSimulatorArm64() iosX64() - jvm("desktop") { - compilerOptions { - jvmTarget.set(JvmTarget.valueOf(project.properties["jvmTarget"]!!.toString())) - } - } + jvm("desktop") { compilerOptions { jvmTarget = project.getJvmTarget() } } js(IR) { browser() } wasmJs { browser() } diff --git a/lib/maplibre-compose-material3/build.gradle.kts b/lib/maplibre-compose-material3/build.gradle.kts index 95b293d9..3b80a83f 100644 --- a/lib/maplibre-compose-material3/build.gradle.kts +++ b/lib/maplibre-compose-material3/build.gradle.kts @@ -2,7 +2,6 @@ import org.jetbrains.compose.ExperimentalComposeLibrary import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi -import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree plugins { @@ -28,20 +27,14 @@ mavenPublishing { kotlin { androidTarget { - compilerOptions { - jvmTarget.set(JvmTarget.valueOf(project.properties["jvmTarget"]!!.toString())) - } + compilerOptions { jvmTarget = project.getJvmTarget() } instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishLibraryVariants("release", "debug") } iosArm64() iosSimulatorArm64() iosX64() - jvm("desktop") { - compilerOptions { - jvmTarget.set(JvmTarget.valueOf(project.properties["jvmTarget"]!!.toString())) - } - } + jvm("desktop") { compilerOptions { jvmTarget = project.getJvmTarget() } } js(IR) { browser() } cocoapods { diff --git a/lib/maplibre-compose/build.gradle.kts b/lib/maplibre-compose/build.gradle.kts index 80717fe2..ae582597 100644 --- a/lib/maplibre-compose/build.gradle.kts +++ b/lib/maplibre-compose/build.gradle.kts @@ -2,7 +2,6 @@ import org.jetbrains.compose.ExperimentalComposeLibrary import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi -import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree plugins { @@ -47,20 +46,14 @@ val copyDesktopResources by kotlin { androidTarget { - compilerOptions { - jvmTarget.set(JvmTarget.valueOf(project.properties["jvmTarget"]!!.toString())) - } + compilerOptions { jvmTarget = project.getJvmTarget() } instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishLibraryVariants("release", "debug") } iosArm64() iosSimulatorArm64() iosX64() - jvm("desktop") { - compilerOptions { - jvmTarget.set(JvmTarget.valueOf(project.properties["jvmTarget"]!!.toString())) - } - } + jvm("desktop") { compilerOptions { jvmTarget = project.getJvmTarget() } } js(IR) { browser() } cocoapods {