mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-30 11:02:58 +08:00
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
This commit is contained in:
parent
7544fdf1ed
commit
d0b59863ac
@ -13,7 +13,7 @@
|
|||||||
"IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED": false,
|
"IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED": false,
|
||||||
"IS_GRADLE_PLUGIN_KOTLIN_ENABLED": false,
|
"IS_GRADLE_PLUGIN_KOTLIN_ENABLED": false,
|
||||||
"PACKAGE_NAMESPACE": "io.cordova.helloCordova",
|
"PACKAGE_NAMESPACE": "io.cordova.helloCordova",
|
||||||
"JAVA_SOURCE_COMPATIBILITY": 8,
|
"JAVA_SOURCE_COMPATIBILITY": 11,
|
||||||
"JAVA_TARGET_COMPATIBILITY": 8,
|
"JAVA_TARGET_COMPATIBILITY": 11,
|
||||||
"KOTLIN_JVM_TARGET": null
|
"KOTLIN_JVM_TARGET": null
|
||||||
}
|
}
|
||||||
|
@ -261,33 +261,13 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
|
if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
|
||||||
if (cordovaConfig.KOTLIN_JVM_TARGET == null) {
|
// If KOTLIN_JVM_TARGET is null, fallback to JAVA_TARGET_COMPATIBILITY,
|
||||||
// If the value is null, fallback to JAVA_TARGET_COMPATIBILITY,
|
// as they generally should be equal
|
||||||
// as they generally should be equal
|
cordovaConfig.KOTLIN_JVM_TARGET = cordovaConfig.KOTLIN_JVM_TARGET ?:
|
||||||
def javaTarget = JavaLanguageVersion.of(cordovaConfig.JAVA_TARGET_COMPATIBILITY)
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = cordovaConfig.KOTLIN_JVM_TARGET
|
jvmTarget = JavaLanguageVersion.of(cordovaConfig.KOTLIN_JVM_TARGET)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user