Skip to content

Commit d0b5986

Browse files
authored
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
1 parent 7544fdf commit d0b5986

File tree

2 files changed

+7
-27
lines changed

2 files changed

+7
-27
lines changed

framework/cdv-gradle-config-defaults.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED": false,
1414
"IS_GRADLE_PLUGIN_KOTLIN_ENABLED": false,
1515
"PACKAGE_NAMESPACE": "io.cordova.helloCordova",
16-
"JAVA_SOURCE_COMPATIBILITY": 8,
17-
"JAVA_TARGET_COMPATIBILITY": 8,
16+
"JAVA_SOURCE_COMPATIBILITY": 11,
17+
"JAVA_TARGET_COMPATIBILITY": 11,
1818
"KOTLIN_JVM_TARGET": null
1919
}

templates/project/app/build.gradle

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -261,33 +261,13 @@ android {
261261
}
262262

263263
if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
264-
if (cordovaConfig.KOTLIN_JVM_TARGET == null) {
265-
// If the value is null, fallback to JAVA_TARGET_COMPATIBILITY,
266-
// as they generally should be equal
267-
def javaTarget = JavaLanguageVersion.of(cordovaConfig.JAVA_TARGET_COMPATIBILITY)
268-
269-
// check if javaTarget is <= 8; if so, we need to prefix it with "1."
270-
// Starting with 9 and later, the value can be used as is.
271-
if (javaTarget.compareTo(JavaLanguageVersion.of(8)) <= 0) {
272-
javaTarget = "1." + javaTarget
273-
}
274-
275-
cordovaConfig.KOTLIN_JVM_TARGET = javaTarget
276-
}
277-
278-
// Similar to above, check if kotlin target is <= 8, if so prefix it.
279-
// This allows the user to use consistent set of values in config.xml
280-
// Rather than having to be aware whether the "1."" prefix is needed.
281-
// This check is only done if the value isn't already prefixed with 1.
282-
if (
283-
!cordovaConfig.KOTLIN_JVM_TARGET.startsWith("1.") &&
284-
JavaLanguageVersion.of(cordovaConfig.KOTLIN_JVM_TARGET).compareTo(JavaLanguageVersion.of(8)) <= 0
285-
) {
286-
cordovaConfig.KOTLIN_JVM_TARGET = "1." + cordovaConfig.KOTLIN_JVM_TARGET
287-
}
264+
// If KOTLIN_JVM_TARGET is null, fallback to JAVA_TARGET_COMPATIBILITY,
265+
// as they generally should be equal
266+
cordovaConfig.KOTLIN_JVM_TARGET = cordovaConfig.KOTLIN_JVM_TARGET ?:
267+
cordovaConfig.JAVA_TARGET_COMPATIBILITY
288268

289269
kotlinOptions {
290-
jvmTarget = cordovaConfig.KOTLIN_JVM_TARGET
270+
jvmTarget = JavaLanguageVersion.of(cordovaConfig.KOTLIN_JVM_TARGET)
291271
}
292272
}
293273

0 commit comments

Comments
 (0)