Merge "Add experimental option to target Java 17" am: 78ce8c23de
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2104326 Change-Id: I2657bd024f5d0eabd609ff4df5d1a088b8dbd1f9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
a571b7d389
3 changed files with 23 additions and 2 deletions
|
@ -698,6 +698,10 @@ func (c *config) IsEnvFalse(key string) bool {
|
||||||
return value == "0" || value == "n" || value == "no" || value == "off" || value == "false"
|
return value == "0" || value == "n" || value == "no" || value == "off" || value == "false"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *config) TargetsJava17() bool {
|
||||||
|
return c.IsEnvTrue("EXPERIMENTAL_TARGET_JAVA_VERSION_17")
|
||||||
|
}
|
||||||
|
|
||||||
// EnvDeps returns the environment variables this build depends on. The first
|
// EnvDeps returns the environment variables this build depends on. The first
|
||||||
// call to this function blocks future reads from the environment.
|
// call to this function blocks future reads from the environment.
|
||||||
func (c *config) EnvDeps() map[string]string {
|
func (c *config) EnvDeps() map[string]string {
|
||||||
|
|
15
java/java.go
15
java/java.go
|
@ -468,6 +468,12 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext an
|
||||||
return normalizeJavaVersion(ctx, javaVersion)
|
return normalizeJavaVersion(ctx, javaVersion)
|
||||||
} else if ctx.Device() {
|
} else if ctx.Device() {
|
||||||
return defaultJavaLanguageVersion(ctx, sdkContext.SdkVersion(ctx))
|
return defaultJavaLanguageVersion(ctx, sdkContext.SdkVersion(ctx))
|
||||||
|
} else if ctx.Config().TargetsJava17() {
|
||||||
|
// Temporary experimental flag to be able to try and build with
|
||||||
|
// java version 17 options. The flag, if used, just sets Java
|
||||||
|
// 17 as the default version, leaving any components that
|
||||||
|
// target an older version intact.
|
||||||
|
return JAVA_VERSION_17
|
||||||
} else {
|
} else {
|
||||||
return JAVA_VERSION_11
|
return JAVA_VERSION_11
|
||||||
}
|
}
|
||||||
|
@ -482,6 +488,7 @@ const (
|
||||||
JAVA_VERSION_8 = 8
|
JAVA_VERSION_8 = 8
|
||||||
JAVA_VERSION_9 = 9
|
JAVA_VERSION_9 = 9
|
||||||
JAVA_VERSION_11 = 11
|
JAVA_VERSION_11 = 11
|
||||||
|
JAVA_VERSION_17 = 17
|
||||||
)
|
)
|
||||||
|
|
||||||
func (v javaVersion) String() string {
|
func (v javaVersion) String() string {
|
||||||
|
@ -496,6 +503,8 @@ func (v javaVersion) String() string {
|
||||||
return "1.9"
|
return "1.9"
|
||||||
case JAVA_VERSION_11:
|
case JAVA_VERSION_11:
|
||||||
return "11"
|
return "11"
|
||||||
|
case JAVA_VERSION_17:
|
||||||
|
return "17"
|
||||||
default:
|
default:
|
||||||
return "unsupported"
|
return "unsupported"
|
||||||
}
|
}
|
||||||
|
@ -518,8 +527,10 @@ func normalizeJavaVersion(ctx android.BaseModuleContext, javaVersion string) jav
|
||||||
return JAVA_VERSION_9
|
return JAVA_VERSION_9
|
||||||
case "11":
|
case "11":
|
||||||
return JAVA_VERSION_11
|
return JAVA_VERSION_11
|
||||||
case "10":
|
case "17":
|
||||||
ctx.PropertyErrorf("java_version", "Java language levels 10 is not supported")
|
return JAVA_VERSION_11
|
||||||
|
case "10", "12", "13", "14", "15", "16":
|
||||||
|
ctx.PropertyErrorf("java_version", "Java language level %s is not supported", javaVersion)
|
||||||
return JAVA_VERSION_UNSUPPORTED
|
return JAVA_VERSION_UNSUPPORTED
|
||||||
default:
|
default:
|
||||||
ctx.PropertyErrorf("java_version", "Unrecognized Java language level")
|
ctx.PropertyErrorf("java_version", "Unrecognized Java language level")
|
||||||
|
|
|
@ -57,6 +57,12 @@ func defaultJavaLanguageVersion(ctx android.EarlyModuleContext, s android.SdkSpe
|
||||||
return JAVA_VERSION_8
|
return JAVA_VERSION_8
|
||||||
} else if sdk.FinalOrFutureInt() <= 31 {
|
} else if sdk.FinalOrFutureInt() <= 31 {
|
||||||
return JAVA_VERSION_9
|
return JAVA_VERSION_9
|
||||||
|
} else if ctx.Config().TargetsJava17() {
|
||||||
|
// Temporary experimental flag to be able to try and build with
|
||||||
|
// java version 17 options. The flag, if used, just sets Java
|
||||||
|
// 17 as the default version, leaving any components that
|
||||||
|
// target an older version intact.
|
||||||
|
return JAVA_VERSION_17
|
||||||
} else {
|
} else {
|
||||||
return JAVA_VERSION_11
|
return JAVA_VERSION_11
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue