This is an automated email from the ASF dual-hosted git repository.

erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-android.git


The following commit(s) were added to refs/heads/master by this push:
     new d0b59863 feat!: bump java default targets to 11 (#1784)
d0b59863 is described below

commit d0b59863acd47858609e6b4fa94e7013c8bfc6a9
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Fri Mar 14 11:55:43 2025 +0900

    feat!: bump java default targets to 11 (#1784)
    
    * feat!: bump java source, target & kotlin jvm target to default 11
    * chore!: remove java <= 8 logic
    * refactor: setting of kotlin's jvmTarget
---
 framework/cdv-gradle-config-defaults.json |  4 ++--
 templates/project/app/build.gradle        | 30 +++++-------------------------
 2 files changed, 7 insertions(+), 27 deletions(-)

diff --git a/framework/cdv-gradle-config-defaults.json 
b/framework/cdv-gradle-config-defaults.json
index 5340cdc0..a4ad0996 100644
--- a/framework/cdv-gradle-config-defaults.json
+++ b/framework/cdv-gradle-config-defaults.json
@@ -13,7 +13,7 @@
     "IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED": false,
     "IS_GRADLE_PLUGIN_KOTLIN_ENABLED": false,
     "PACKAGE_NAMESPACE": "io.cordova.helloCordova",
-    "JAVA_SOURCE_COMPATIBILITY": 8,
-    "JAVA_TARGET_COMPATIBILITY": 8,
+    "JAVA_SOURCE_COMPATIBILITY": 11,
+    "JAVA_TARGET_COMPATIBILITY": 11,
     "KOTLIN_JVM_TARGET": null
 }
diff --git a/templates/project/app/build.gradle 
b/templates/project/app/build.gradle
index 5ff337f1..ec46304c 100644
--- a/templates/project/app/build.gradle
+++ b/templates/project/app/build.gradle
@@ -261,33 +261,13 @@ android {
     }
 
     if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
-        if (cordovaConfig.KOTLIN_JVM_TARGET == null) {
-            // If the value is null, fallback to JAVA_TARGET_COMPATIBILITY,
-            // as they generally should be equal
-            def javaTarget = 
JavaLanguageVersion.of(cordovaConfig.JAVA_TARGET_COMPATIBILITY)
-
-            // check if javaTarget is <= 8; if so, we need to prefix it with 
"1."
-            // Starting with 9 and later, the value can be used as is.
-            if (javaTarget.compareTo(JavaLanguageVersion.of(8)) <= 0) {
-                javaTarget = "1." + javaTarget
-            }
-
-            cordovaConfig.KOTLIN_JVM_TARGET = javaTarget
-        }
-
-        // Similar to above, check if kotlin target is <= 8, if so prefix it.
-        // This allows the user to use consistent set of values in config.xml
-        // Rather than having to be aware whether the "1."" prefix is needed.
-        // This check is only done if the value isn't already prefixed with 1.
-        if (
-            !cordovaConfig.KOTLIN_JVM_TARGET.startsWith("1.") &&
-            
JavaLanguageVersion.of(cordovaConfig.KOTLIN_JVM_TARGET).compareTo(JavaLanguageVersion.of(8))
 <= 0
-        ) {
-            cordovaConfig.KOTLIN_JVM_TARGET = "1." + 
cordovaConfig.KOTLIN_JVM_TARGET
-        }
+        // If KOTLIN_JVM_TARGET is null, fallback to JAVA_TARGET_COMPATIBILITY,
+        // as they generally should be equal
+        cordovaConfig.KOTLIN_JVM_TARGET = cordovaConfig.KOTLIN_JVM_TARGET ?:
+                cordovaConfig.JAVA_TARGET_COMPATIBILITY
 
         kotlinOptions {
-            jvmTarget = cordovaConfig.KOTLIN_JVM_TARGET
+            jvmTarget = JavaLanguageVersion.of(cordovaConfig.KOTLIN_JVM_TARGET)
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org

Reply via email to