Adding option to include sources only for Java 11 builds

Bug: 207852002
Test: m
Test: EXPERIMENTAL_TARGET_JAVA_VERSION_11=true m
Change-Id: I554a79798ea7f1dd4a96b09f761090f83a009cb4
This commit is contained in:
Sorin Basca
2021-12-20 11:51:24 +00:00
parent f1228f570a
commit 9347ae3ba0
5 changed files with 24 additions and 2 deletions

View File

@@ -122,6 +122,14 @@ type CommonProperties struct {
Javacflags []string
}
Openjdk11 struct {
// List of source files that should only be used when passing -source 1.9 or higher
Srcs []string `android:"path"`
// List of javac flags that should only be used when passing -source 1.9 or higher
Javacflags []string
}
// When compiling language level 9+ .java code in packages that are part of
// a system module, patch_module names the module that your sources and
// dependencies should be patched into. The Android runtime currently
@@ -959,6 +967,10 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
if flags.javaVersion.usesJavaModules() {
j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk9.Srcs...)
}
if ctx.Config().TargetsJava11() {
j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk11.Srcs...)
}
srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
if hasSrcExt(srcFiles.Strings(), ".proto") {
flags = protoFlags(ctx, &j.properties, &j.protoProperties, flags)