Skip to content

Commit aebf38c

Browse files
authored
android: Migrate Gradle scripts to compilerOptions DSL (#15694)
Kotlin Gradle Plugin deprecated the string-based `kotlinOptions` DSL and 2.3+ rejects it with a hard error. Use the `compilerOptions` DSL with `JvmTarget.JVM_1_8` instead, which is accepted on both 1.9.x and 2.x, so projects can move to Kotlin 2.x without editing the vendored `:tauri-android` scripts.
1 parent d8ee620 commit aebf38c

5 files changed

Lines changed: 36 additions & 10 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri": patch:enhance
3+
"tauri-cli": patch:enhance
4+
"@tauri-apps/cli": patch:enhance
5+
---
6+
7+
Migrate the Android Gradle scripts from the deprecated `kotlinOptions` DSL to `compilerOptions`, which is accepted by both Kotlin Gradle Plugin 1.9.x and 2.x. This lets projects move to Kotlin 2.x without hitting the hard error that 2.3+ raises on the old DSL.

‎crates/tauri-cli/templates/mobile/android/app/build.gradle.kts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
12
import java.util.Properties
23

34
plugins {
@@ -50,14 +51,17 @@ android {
5051
)
5152
}
5253
}
53-
kotlinOptions {
54-
jvmTarget = "1.8"
55-
}
5654
buildFeatures {
5755
buildConfig = true
5856
}
5957
}
6058

59+
kotlin {
60+
compilerOptions {
61+
jvmTarget = JvmTarget.JVM_1_8
62+
}
63+
}
64+
6165
rust {
6266
rootDirRel = "{{root-dir-rel}}"
6367
}

‎crates/tauri-cli/templates/plugin/android/build.gradle.kts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
plugins {
24
id("com.android.library")
35
id("org.jetbrains.kotlin.android")
@@ -27,8 +29,11 @@ android {
2729
sourceCompatibility = JavaVersion.VERSION_1_8
2830
targetCompatibility = JavaVersion.VERSION_1_8
2931
}
30-
kotlinOptions {
31-
jvmTarget = "1.8"
32+
}
33+
34+
kotlin {
35+
compilerOptions {
36+
jvmTarget = JvmTarget.JVM_1_8
3237
}
3338
}
3439

‎crates/tauri/mobile/android/build.gradle.kts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
plugins {
24
id("com.android.library")
35
id("org.jetbrains.kotlin.android")
@@ -27,14 +29,17 @@ android {
2729
sourceCompatibility = JavaVersion.VERSION_1_8
2830
targetCompatibility = JavaVersion.VERSION_1_8
2931
}
30-
kotlinOptions {
31-
jvmTarget = "1.8"
32-
}
3332
buildFeatures {
3433
buildConfig = true
3534
}
3635
}
3736

37+
kotlin {
38+
compilerOptions {
39+
jvmTarget = JvmTarget.JVM_1_8
40+
}
41+
}
42+
3843
dependencies {
3944

4045
implementation("androidx.core:core-ktx:1.7.0")

‎examples/api/src-tauri/tauri-plugin-sample/android/build.gradle.kts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
plugins {
24
id("com.android.library")
35
id("org.jetbrains.kotlin.android")
@@ -27,8 +29,11 @@ android {
2729
sourceCompatibility = JavaVersion.VERSION_1_8
2830
targetCompatibility = JavaVersion.VERSION_1_8
2931
}
30-
kotlinOptions {
31-
jvmTarget = "1.8"
32+
}
33+
34+
kotlin {
35+
compilerOptions {
36+
jvmTarget = JvmTarget.JVM_1_8
3237
}
3338
}
3439

0 commit comments

Comments
 (0)