Disable automatic JVM target 1.8 detection in Android projects, KT-31027
This is a soft revert of the fix for KT-21030 (commit ffbd0e8a).
The logic introduced for KT-21030 should now only run when a property
flag is provided, kotlin.setJvmTargetFromAndroidCompileOptions.
We can't set the JVM target to 1.8 automatically until an Android Gradle
plugin version appears that can correctly desugar the bytecode produced
by the Kotlin compiler.
So we disable the logic introduced in the fix for KT-26432
with the plan to enable it back and apply it conditionally once there is
an Android Gradle plugin version that processes the calls correctly.
Issue #KT-31027 Fixed
This commit is contained in:
+7
-2
@@ -680,7 +680,7 @@ fun getSomething() = 10
|
||||
|
||||
val kotlinJvmTarget18Regex = Regex("Kotlin compiler args: .* -jvm-target 1.8")
|
||||
|
||||
build(":Lib:assemble") {
|
||||
build(":Lib:assembleDebug", "-Pkotlin.setJvmTargetFromAndroidCompileOptions=true") {
|
||||
assertSuccessful()
|
||||
assertNotContains(kotlinJvmTarget18Regex)
|
||||
}
|
||||
@@ -694,7 +694,12 @@ fun getSomething() = 10
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
build(":Lib:assemble") {
|
||||
build("clean", ":Lib:assembleDebug") {
|
||||
assertSuccessful()
|
||||
assertNotContains(kotlinJvmTarget18Regex)
|
||||
}
|
||||
|
||||
build(":Lib:assembleDebug", "-Pkotlin.setJvmTargetFromAndroidCompileOptions=true") {
|
||||
assertSuccessful()
|
||||
assertContainsRegex(kotlinJvmTarget18Regex)
|
||||
}
|
||||
|
||||
+7
-1
@@ -735,7 +735,13 @@ abstract class AbstractAndroidProjectHandler<V>(private val kotlinConfigurationT
|
||||
|
||||
val kotlinOptions = KotlinJvmOptionsImpl()
|
||||
project.whenEvaluated {
|
||||
applyAndroidJavaVersion(project.extensions.getByType(BaseExtension::class.java), kotlinOptions)
|
||||
// TODO don't require the flag once there is an Android Gradle plugin build that supports desugaring of Long.hashCode and
|
||||
// Boolean.hashCode. Instead, run conditionally, only with the AGP versions that play well with Kotlin bytecode for
|
||||
// JVM target 1.8.
|
||||
// See: KT-31027
|
||||
if (PropertiesProvider(project).setJvmTargetFromAndroidCompileOptions == true) {
|
||||
applyAndroidJavaVersion(project.extensions.getByType(BaseExtension::class.java), kotlinOptions)
|
||||
}
|
||||
}
|
||||
|
||||
kotlinOptions.noJdk = true
|
||||
|
||||
+3
@@ -85,6 +85,9 @@ internal class PropertiesProvider(private val project: Project) {
|
||||
val ignorePluginLoadedInMultipleProjects: Boolean?
|
||||
get() = booleanProperty("kotlin.pluginLoadedInMultipleProjects.ignore")
|
||||
|
||||
val setJvmTargetFromAndroidCompileOptions: Boolean?
|
||||
get() = booleanProperty("kotlin.setJvmTargetFromAndroidCompileOptions")
|
||||
|
||||
/**
|
||||
* Enables parallel tasks execution within a project with Workers API.
|
||||
* Does not enable using actual worker proccesses
|
||||
|
||||
Reference in New Issue
Block a user