Use the current java version for -jvm-target
This is a partial revert of aosp/541879. In that cl, the kotlin jvm version was always set to 1.8 because that's what the kotlin complier supported at the time, but now it supports more versions: $ ./external/kotlinc/bin/kotlinc -jvm-target foo error: unknown JVM target version: foo Supported versions: 1.6, 1.8, 9, 10, 11, 12, 13, 14, 15, 16, 17 Bug: 69160377 Bug: 236431222 Test: Treehugger Change-Id: I273e0b4d1f484013889e17c60bc1b299a3f975a1
This commit is contained in:
14
java/java.go
14
java/java.go
@@ -510,6 +510,20 @@ func (v javaVersion) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (v javaVersion) StringForKotlinc() string {
|
||||
// $ ./external/kotlinc/bin/kotlinc -jvm-target foo
|
||||
// error: unknown JVM target version: foo
|
||||
// Supported versions: 1.6, 1.8, 9, 10, 11, 12, 13, 14, 15, 16, 17
|
||||
switch v {
|
||||
case JAVA_VERSION_7:
|
||||
return "1.6"
|
||||
case JAVA_VERSION_9:
|
||||
return "9"
|
||||
default:
|
||||
return v.String()
|
||||
}
|
||||
}
|
||||
|
||||
// Returns true if javac targeting this version uses system modules instead of a bootclasspath.
|
||||
func (v javaVersion) usesJavaModules() bool {
|
||||
return v >= 9
|
||||
|
@@ -119,9 +119,8 @@ func kotlinCompile(ctx android.ModuleContext, outputFile, headerOutputFile andro
|
||||
"srcJarDir": android.PathForModuleOut(ctx, "kotlinc", "srcJars").String(),
|
||||
"kotlinBuildFile": android.PathForModuleOut(ctx, "kotlinc-build.xml").String(),
|
||||
"emptyDir": android.PathForModuleOut(ctx, "kotlinc", "empty").String(),
|
||||
// http://b/69160377 kotlinc only supports -jvm-target 1.6 and 1.8
|
||||
"kotlinJvmTarget": "1.8",
|
||||
"name": kotlinName,
|
||||
"kotlinJvmTarget": flags.javaVersion.StringForKotlinc(),
|
||||
"name": kotlinName,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user