summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go361
1 files changed, 221 insertions, 140 deletions
diff --git a/java/java.go b/java/java.go
index bd5f6b7d5..d5375a5b3 100644
--- a/java/java.go
+++ b/java/java.go
@@ -44,7 +44,7 @@ func init() {
PropertyName: "java_libs",
},
func(j *Library) android.Path {
- implementationJars := j.ImplementationJars()
+ implementationJars := j.ImplementationAndResourcesJars()
if len(implementationJars) != 1 {
panic(fmt.Errorf("there must be only one implementation jar from %q", j.Name()))
}
@@ -140,10 +140,15 @@ func (j *Module) checkPlatformAPI(ctx android.ModuleContext) {
// Findbugs
type CompilerProperties struct {
- // list of source files used to compile the Java module. May be .java, .logtags, .proto,
+ // list of source files used to compile the Java module. May be .java, .kt, .logtags, .proto,
// or .aidl files.
Srcs []string `android:"path,arch_variant"`
+ // list Kotlin of source files containing Kotlin code that should be treated as common code in
+ // a codebase that supports Kotlin multiplatform. See
+ // https://kotlinlang.org/docs/reference/multiplatform.html. May be only be .kt files.
+ Common_srcs []string `android:"path,arch_variant"`
+
// list of source files that should not be used to build the Java module.
// This is most useful in the arch/multilib variants to remove non-common files
Exclude_srcs []string `android:"path,arch_variant"`
@@ -253,12 +258,12 @@ type CompilerProperties struct {
// List of files to include in the META-INF/services folder of the resulting jar.
Services []string `android:"path,arch_variant"`
+
+ // If true, package the kotlin stdlib into the jar. Defaults to true.
+ Static_kotlin_stdlib *bool `android:"arch_variant"`
}
type CompilerDeviceProperties struct {
- // list of module-specific flags that will be used for dex compiles
- Dxflags []string `android:"arch_variant"`
-
// if not blank, set to the version of the sdk to compile against.
// Defaults to compiling against the current platform.
Sdk_version *string
@@ -304,57 +309,22 @@ type CompilerDeviceProperties struct {
}
}
- // If set to true, compile dex regardless of installable. Defaults to false.
- Compile_dex *bool
-
- Optimize struct {
- // If false, disable all optimization. Defaults to true for android_app and android_test
- // modules, false for java_library and java_test modules.
- Enabled *bool
- // True if the module containing this has it set by default.
- EnabledByDefault bool `blueprint:"mutated"`
-
- // If true, optimize for size by removing unused code. Defaults to true for apps,
- // false for libraries and tests.
- Shrink *bool
-
- // If true, optimize bytecode. Defaults to false.
- Optimize *bool
-
- // If true, obfuscate bytecode. Defaults to false.
- Obfuscate *bool
-
- // If true, do not use the flag files generated by aapt that automatically keep
- // classes referenced by the app manifest. Defaults to false.
- No_aapt_flags *bool
-
- // Flags to pass to proguard.
- Proguard_flags []string
-
- // Specifies the locations of files containing proguard flags.
- Proguard_flags_files []string `android:"path"`
- }
-
// When targeting 1.9 and above, override the modules to use with --system,
// otherwise provides defaults libraries to add to the bootclasspath.
System_modules *string
+ // The name of the module as used in build configuration.
+ //
+ // Allows a library to separate its actual name from the name used in
+ // build configuration, e.g.ctx.Config().BootJars().
+ ConfigurationName *string `blueprint:"mutated"`
+
// set the name of the output
Stem *string
- // Keep the data uncompressed. We always need uncompressed dex for execution,
- // so this might actually save space by avoiding storing the same data twice.
- // This defaults to reasonable value based on module and should not be set.
- // It exists only to support ART tests.
- Uncompress_dex *bool
-
IsSDKLibrary bool `blueprint:"mutated"`
}
-func (me *CompilerDeviceProperties) EffectiveOptimizeEnabled() bool {
- return BoolDefault(me.Optimize.Enabled, me.Optimize.EnabledByDefault)
-}
-
// Functionality common to Module and Import
//
// It is embedded in Module so its functionality can be used by methods in Module
@@ -423,9 +393,6 @@ type Module struct {
// output file containing uninstrumented classes that will be instrumented by jacoco
jacocoReportClassesFile android.Path
- // output file containing mapping of obfuscated names
- proguardDictionary android.Path
-
// output file of the module, which may be a classes jar or a dex jar
outputFile android.Path
extraOutputFiles android.Paths
@@ -441,9 +408,6 @@ type Module struct {
compiledJavaSrcs android.Paths
compiledSrcJars android.Paths
- // list of extra progurad flag files
- extraProguardFlagFiles android.Paths
-
// manifest file to use instead of properties.Manifest
overrideManifest android.OptionalPath
@@ -470,17 +434,36 @@ type Module struct {
extraResources android.Paths
hiddenAPI
+ dexer
dexpreopter
+ linter
// list of the xref extraction files
kytheFiles android.Paths
- distFile android.Path
+ distFiles android.TaggedDistFiles
// Collect the module directory for IDE info in java/jdeps.go.
modulePaths []string
}
+func (j *Module) addHostProperties() {
+ j.AddProperties(
+ &j.properties,
+ &j.protoProperties,
+ )
+}
+
+func (j *Module) addHostAndDeviceProperties() {
+ j.addHostProperties()
+ j.AddProperties(
+ &j.deviceProperties,
+ &j.dexer.dexProperties,
+ &j.dexpreoptProperties,
+ &j.linter.properties,
+ )
+}
+
func (j *Module) OutputFiles(tag string) (android.Paths, error) {
switch tag {
case "":
@@ -488,7 +471,10 @@ func (j *Module) OutputFiles(tag string) (android.Paths, error) {
case ".jar":
return android.Paths{j.implementationAndResourcesJar}, nil
case ".proguard_map":
- return android.Paths{j.proguardDictionary}, nil
+ if j.dexer.proguardDictionary.Valid() {
+ return android.Paths{j.dexer.proguardDictionary.Path()}, nil
+ }
+ return nil, fmt.Errorf("%q was requested, but no output file was found.", tag)
default:
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
}
@@ -496,11 +482,16 @@ func (j *Module) OutputFiles(tag string) (android.Paths, error) {
var _ android.OutputFileProducer = (*Module)(nil)
-type Dependency interface {
+// Methods that need to be implemented for a module that is added to apex java_libs property.
+type ApexDependency interface {
HeaderJars() android.Paths
+ ImplementationAndResourcesJars() android.Paths
+}
+
+type Dependency interface {
+ ApexDependency
ImplementationJars() android.Paths
ResourceJars() android.Paths
- ImplementationAndResourcesJars() android.Paths
DexJarBuildPath() android.Path
DexJarInstallPath() android.Path
AidlIncludeDirs() android.Paths
@@ -520,7 +511,20 @@ func (j *Module) XrefJavaFiles() android.Paths {
}
func InitJavaModule(module android.DefaultableModule, hod android.HostOrDeviceSupported) {
- android.InitAndroidArchModule(module, hod, android.MultilibCommon)
+ initJavaModule(module, hod, false)
+}
+
+func InitJavaModuleMultiTargets(module android.DefaultableModule, hod android.HostOrDeviceSupported) {
+ initJavaModule(module, hod, true)
+}
+
+func initJavaModule(module android.DefaultableModule, hod android.HostOrDeviceSupported, multiTargets bool) {
+ multilib := android.MultilibCommon
+ if multiTargets {
+ android.InitAndroidMultiTargetsArchModule(module, hod, multilib)
+ } else {
+ android.InitAndroidArchModule(module, hod, multilib)
+ }
android.InitDefaultableModule(module)
}
@@ -539,6 +543,7 @@ func IsJniDepTag(depTag blueprint.DependencyTag) bool {
}
var (
+ dataNativeBinsTag = dependencyTag{name: "dataNativeBins"}
staticLibTag = dependencyTag{name: "staticlib"}
libTag = dependencyTag{name: "javalib"}
java9LibTag = dependencyTag{name: "java9lib"}
@@ -554,6 +559,7 @@ var (
certificateTag = dependencyTag{name: "certificate"}
instrumentationForTag = dependencyTag{name: "instrumentation_for"}
usesLibTag = dependencyTag{name: "uses-library"}
+ extraLintCheckTag = dependencyTag{name: "extra-lint-check"}
)
func IsLibDepTag(depTag blueprint.DependencyTag) bool {
@@ -565,7 +571,7 @@ func IsStaticLibDepTag(depTag blueprint.DependencyTag) bool {
}
type sdkDep struct {
- useModule, useFiles, useDefaultLibs, invalidVersion bool
+ useModule, useFiles, invalidVersion bool
// The modules that will be added to the bootclasspath when targeting 1.8 or lower
bootclasspath []string
@@ -574,7 +580,11 @@ type sdkDep struct {
// modules are to be used.
systemModules string
+ // The modules that will be added to the classpath regardless of the Java language level targeted
+ classpath []string
+
// The modules that will be added ot the classpath when targeting 1.9 or higher
+ // (normally these will be on the bootclasspath when targeting 1.8 or lower)
java9Classpath []string
frameworkResModule string
@@ -594,10 +604,11 @@ func (s sdkDep) hasFrameworkLibs() bool {
}
type jniLib struct {
- name string
- path android.Path
- target android.Target
- coverageFile android.OptionalPath
+ name string
+ path android.Path
+ target android.Target
+ coverageFile android.OptionalPath
+ unstrippedFile android.Path
}
func (j *Module) shouldInstrument(ctx android.BaseModuleContext) bool {
@@ -665,19 +676,18 @@ func (j *Module) AvailableFor(what string) bool {
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
if ctx.Device() {
+ j.linter.deps(ctx)
+
sdkDep := decodeSdkDep(ctx, sdkContext(j))
- if sdkDep.useDefaultLibs {
- ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
- ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
- if sdkDep.hasFrameworkLibs() {
- ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
- }
- } else if sdkDep.useModule {
+ if sdkDep.useModule {
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...)
ctx.AddVariationDependencies(nil, java9LibTag, sdkDep.java9Classpath...)
- if j.deviceProperties.EffectiveOptimizeEnabled() && sdkDep.hasStandardLibs() {
- ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultBootclasspathLibraries...)
- ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultLibraries...)
+ ctx.AddVariationDependencies(nil, libTag, sdkDep.classpath...)
+ if j.effectiveOptimizeEnabled() && sdkDep.hasStandardLibs() {
+ ctx.AddVariationDependencies(nil, proguardRaiseTag, config.LegacyCorePlatformBootclasspathLibraries...)
+ }
+ if j.effectiveOptimizeEnabled() && sdkDep.hasFrameworkLibs() {
+ ctx.AddVariationDependencies(nil, proguardRaiseTag, config.FrameworkLibraries...)
}
}
if sdkDep.systemModules != "" {
@@ -1265,6 +1275,11 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
flags = protoFlags(ctx, &j.properties, &j.protoProperties, flags)
}
+ kotlinCommonSrcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Common_srcs, nil)
+ if len(kotlinCommonSrcFiles.FilterOutByExt(".kt")) > 0 {
+ ctx.PropertyErrorf("common_srcs", "common_srcs must be .kt files")
+ }
+
srcFiles = j.genSources(ctx, srcFiles, flags)
srcJars := srcFiles.FilterByExt(".srcjar")
@@ -1318,6 +1333,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
// Collect .kt files for AIDEGen
j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, srcFiles.FilterByExt(".kt").Strings()...)
+ j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, kotlinCommonSrcFiles.Strings()...)
flags.classpath = append(flags.classpath, deps.kotlinStdlib...)
flags.classpath = append(flags.classpath, deps.kotlinAnnotations...)
@@ -1328,15 +1344,17 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
if len(flags.processorPath) > 0 {
// Use kapt for annotation processing
kaptSrcJar := android.PathForModuleOut(ctx, "kapt", "kapt-sources.jar")
- kotlinKapt(ctx, kaptSrcJar, kotlinSrcFiles, srcJars, flags)
+ kaptResJar := android.PathForModuleOut(ctx, "kapt", "kapt-res.jar")
+ kotlinKapt(ctx, kaptSrcJar, kaptResJar, kotlinSrcFiles, kotlinCommonSrcFiles, srcJars, flags)
srcJars = append(srcJars, kaptSrcJar)
+ kotlinJars = append(kotlinJars, kaptResJar)
// Disable annotation processing in javac, it's already been handled by kapt
flags.processorPath = nil
flags.processors = nil
}
kotlinJar := android.PathForModuleOut(ctx, "kotlin", jarName)
- kotlinCompile(ctx, kotlinJar, kotlinSrcFiles, srcJars, flags)
+ kotlinCompile(ctx, kotlinJar, kotlinSrcFiles, kotlinCommonSrcFiles, srcJars, flags)
if ctx.Failed() {
return
}
@@ -1344,9 +1362,11 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
// Make javac rule depend on the kotlinc rule
flags.classpath = append(flags.classpath, kotlinJar)
- // Jar kotlin classes into the final jar after javac
kotlinJars = append(kotlinJars, kotlinJar)
- kotlinJars = append(kotlinJars, deps.kotlinStdlib...)
+ // Jar kotlin classes into the final jar after javac
+ if BoolDefault(j.properties.Static_kotlin_stdlib, true) {
+ kotlinJars = append(kotlinJars, deps.kotlinStdlib...)
+ }
}
jars := append(android.Paths(nil), kotlinJars...)
@@ -1582,8 +1602,8 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
// Enable dex compilation for the APEX variants, unless it is disabled explicitly
if android.DirectlyInAnyApex(ctx, ctx.ModuleName()) && !j.IsForPlatform() {
- if j.deviceProperties.Compile_dex == nil {
- j.deviceProperties.Compile_dex = proptools.BoolPtr(true)
+ if j.dexProperties.Compile_dex == nil {
+ j.dexProperties.Compile_dex = proptools.BoolPtr(true)
}
if j.deviceProperties.Hostdex == nil {
j.deviceProperties.Hostdex = proptools.BoolPtr(true)
@@ -1591,17 +1611,24 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
}
if ctx.Device() && j.hasCode(ctx) &&
- (Bool(j.properties.Installable) || Bool(j.deviceProperties.Compile_dex)) {
+ (Bool(j.properties.Installable) || Bool(j.dexProperties.Compile_dex)) {
+ if j.shouldInstrumentStatic(ctx) {
+ j.dexer.extraProguardFlagFiles = append(j.dexer.extraProguardFlagFiles,
+ android.PathForSource(ctx, "build/make/core/proguard.jacoco.flags"))
+ }
// Dex compilation
var dexOutputFile android.ModuleOutPath
- dexOutputFile = j.compileDex(ctx, flags, outputFile, jarName)
+ dexOutputFile = j.dexer.compileDex(ctx, flags, j.minSdkVersion(), outputFile, jarName)
if ctx.Failed() {
return
}
+ configurationName := j.ConfigurationName()
+ primary := configurationName == ctx.ModuleName()
+
// Hidden API CSV generation and dex encoding
- dexOutputFile = j.hiddenAPI.hiddenAPI(ctx, dexOutputFile, j.implementationJarFile,
- proptools.Bool(j.deviceProperties.Uncompress_dex))
+ dexOutputFile = j.hiddenAPI.hiddenAPI(ctx, configurationName, primary, dexOutputFile, j.implementationJarFile,
+ proptools.Bool(j.dexProperties.Uncompress_dex))
// merge dex jar with resources if necessary
if j.resourceJar != nil {
@@ -1609,7 +1636,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
combinedJar := android.PathForModuleOut(ctx, "dex-withres", jarName)
TransformJarsToJar(ctx, combinedJar, "for dex resources", jars, android.OptionalPath{},
false, nil, nil)
- if *j.deviceProperties.Uncompress_dex {
+ if *j.dexProperties.Uncompress_dex {
combinedAlignedJar := android.PathForModuleOut(ctx, "dex-withres-aligned", jarName)
TransformZipAlign(ctx, combinedAlignedJar, combinedJar)
dexOutputFile = combinedAlignedJar
@@ -1634,6 +1661,31 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
outputFile = implementationAndResourcesJar
}
+ if ctx.Device() {
+ lintSDKVersionString := func(sdkSpec sdkSpec) string {
+ if v := sdkSpec.version; v.isNumbered() {
+ return v.String()
+ } else {
+ return ctx.Config().DefaultAppTargetSdk()
+ }
+ }
+
+ j.linter.name = ctx.ModuleName()
+ j.linter.srcs = srcFiles
+ j.linter.srcJars = srcJars
+ j.linter.classpath = append(append(android.Paths(nil), flags.bootClasspath...), flags.classpath...)
+ j.linter.classes = j.implementationJarFile
+ j.linter.minSdkVersion = lintSDKVersionString(j.minSdkVersion())
+ j.linter.targetSdkVersion = lintSDKVersionString(j.targetSdkVersion())
+ j.linter.compileSdkVersion = lintSDKVersionString(j.sdkVersion())
+ j.linter.javaLanguageLevel = flags.javaVersion.String()
+ j.linter.kotlinLanguageLevel = "1.3"
+ if j.ApexName() != "" && ctx.Config().UnbundledBuildApps() {
+ j.linter.buildModuleReportZip = true
+ }
+ j.linter.lint(ctx)
+ }
+
ctx.CheckbuildFile(outputFile)
// Save the output file with no relative path so that it doesn't end up in a subdirectory when used as a resource
@@ -1833,10 +1885,32 @@ func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
return j.depIsInSameApex(ctx, dep)
}
+func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error {
+ sdkSpec := j.minSdkVersion()
+ if !sdkSpec.specified() {
+ return fmt.Errorf("min_sdk_version is not specified")
+ }
+ if sdkSpec.kind == sdkCore {
+ return nil
+ }
+ ver, err := sdkSpec.effectiveVersion(ctx)
+ if err != nil {
+ return err
+ }
+ if int(ver) > sdkVersion {
+ return fmt.Errorf("newer SDK(%v)", ver)
+ }
+ return nil
+}
+
func (j *Module) Stem() string {
return proptools.StringDefault(j.deviceProperties.Stem, j.Name())
}
+func (j *Module) ConfigurationName() string {
+ return proptools.StringDefault(j.deviceProperties.ConfigurationName, j.BaseModuleName())
+}
+
func (j *Module) JacocoReportClassesFile() android.Path {
return j.jacocoReportClassesFile
}
@@ -1849,18 +1923,9 @@ func (j *Module) IsInstallable() bool {
// Java libraries (.jar file)
//
-type LibraryProperties struct {
- Dist struct {
- // The tag of the output of this module that should be output.
- Tag *string `android:"arch_variant"`
- } `android:"arch_variant"`
-}
-
type Library struct {
Module
- libraryProperties LibraryProperties
-
InstallMixin func(ctx android.ModuleContext, installPath android.Path) (extraInstallDeps android.Paths)
}
@@ -1902,11 +1967,11 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.checkSdkVersions(ctx)
j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", j.Stem()+".jar")
j.dexpreopter.isSDKLibrary = j.deviceProperties.IsSDKLibrary
- if j.deviceProperties.Uncompress_dex == nil {
+ if j.dexProperties.Uncompress_dex == nil {
// If the value was not force-set by the user, use reasonable default based on the module.
- j.deviceProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter))
+ j.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter))
}
- j.dexpreopter.uncompressedDex = *j.deviceProperties.Uncompress_dex
+ j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
j.compile(ctx, nil)
// Collect the module directory for IDE info in java/jdeps.go.
@@ -1922,14 +1987,7 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.Stem()+".jar", j.outputFile, extraInstallDeps...)
}
- // Verify Dist.Tag is set to a supported output
- if j.libraryProperties.Dist.Tag != nil {
- distFiles, err := j.OutputFiles(*j.libraryProperties.Dist.Tag)
- if err != nil {
- ctx.PropertyErrorf("dist.tag", "%s", err.Error())
- }
- j.distFile = distFiles[0]
- }
+ j.distFiles = j.GenerateTaggedDistFiles(ctx)
}
func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -2046,12 +2104,7 @@ var javaHeaderLibsSdkMemberType android.SdkMemberType = &librarySdkMemberType{
func LibraryFactory() android.Module {
module := &Library{}
- module.AddProperties(
- &module.Module.properties,
- &module.Module.deviceProperties,
- &module.Module.dexpreoptProperties,
- &module.Module.protoProperties,
- &module.libraryProperties)
+ module.addHostAndDeviceProperties()
module.initModuleAndImport(&module.ModuleBase)
@@ -2073,9 +2126,7 @@ func LibraryStaticFactory() android.Module {
func LibraryHostFactory() android.Module {
module := &Library{}
- module.AddProperties(
- &module.Module.properties,
- &module.Module.protoProperties)
+ module.addHostProperties()
module.Module.properties.Installable = proptools.BoolPtr(true)
@@ -2115,6 +2166,11 @@ type testProperties struct {
Test_mainline_modules []string
}
+type hostTestProperties struct {
+ // list of native binary modules that should be installed alongside the test
+ Data_native_bins []string `android:"arch_variant"`
+}
+
type testHelperLibraryProperties struct {
// list of compatibility suites (for example "cts", "vts") that the module should be
// installed into.
@@ -2140,6 +2196,12 @@ type Test struct {
data android.Paths
}
+type TestHost struct {
+ Test
+
+ testHostProperties hostTestProperties
+}
+
type TestHelperLibrary struct {
Library
@@ -2154,11 +2216,26 @@ type JavaTestImport struct {
testConfig android.Path
}
+func (j *TestHost) DepsMutator(ctx android.BottomUpMutatorContext) {
+ if len(j.testHostProperties.Data_native_bins) > 0 {
+ for _, target := range ctx.MultiTargets() {
+ ctx.AddVariationDependencies(target.Variations(), dataNativeBinsTag, j.testHostProperties.Data_native_bins...)
+ }
+ }
+
+ j.deps(ctx)
+}
+
func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template,
j.testProperties.Test_suites, j.testProperties.Auto_gen_config)
+
j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data)
+ ctx.VisitDirectDepsWithTag(dataNativeBinsTag, func(dep android.Module) {
+ j.data = append(j.data, android.OutputFileForModule(ctx, dep, ""))
+ })
+
j.Library.GenerateAndroidBuildActions(ctx)
}
@@ -2243,15 +2320,12 @@ func (p *testSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext,
func TestFactory() android.Module {
module := &Test{}
- module.AddProperties(
- &module.Module.properties,
- &module.Module.deviceProperties,
- &module.Module.dexpreoptProperties,
- &module.Module.protoProperties,
- &module.testProperties)
+ module.addHostAndDeviceProperties()
+ module.AddProperties(&module.testProperties)
module.Module.properties.Installable = proptools.BoolPtr(true)
module.Module.dexpreopter.isTest = true
+ module.Module.linter.test = true
InitJavaModule(module, android.HostAndDeviceSupported)
return module
@@ -2261,15 +2335,12 @@ func TestFactory() android.Module {
func TestHelperLibraryFactory() android.Module {
module := &TestHelperLibrary{}
- module.AddProperties(
- &module.Module.properties,
- &module.Module.deviceProperties,
- &module.Module.dexpreoptProperties,
- &module.Module.protoProperties,
- &module.testHelperLibraryProperties)
+ module.addHostAndDeviceProperties()
+ module.AddProperties(&module.testHelperLibraryProperties)
module.Module.properties.Installable = proptools.BoolPtr(true)
module.Module.dexpreopter.isTest = true
+ module.Module.linter.test = true
InitJavaModule(module, android.HostAndDeviceSupported)
return module
@@ -2305,16 +2376,15 @@ func JavaTestImportFactory() android.Module {
// A java_test_host has a single variant that produces a `.jar` file containing `.class` files that were
// compiled against the host bootclasspath.
func TestHostFactory() android.Module {
- module := &Test{}
+ module := &TestHost{}
- module.AddProperties(
- &module.Module.properties,
- &module.Module.protoProperties,
- &module.testProperties)
+ module.addHostProperties()
+ module.AddProperties(&module.testProperties)
+ module.AddProperties(&module.testHostProperties)
module.Module.properties.Installable = proptools.BoolPtr(true)
- InitJavaModule(module, android.HostSupported)
+ InitJavaModuleMultiTargets(module, android.HostSupported)
return module
}
@@ -2394,12 +2464,8 @@ func (j *Binary) DepsMutator(ctx android.BottomUpMutatorContext) {
func BinaryFactory() android.Module {
module := &Binary{}
- module.AddProperties(
- &module.Module.properties,
- &module.Module.deviceProperties,
- &module.Module.dexpreoptProperties,
- &module.Module.protoProperties,
- &module.binaryProperties)
+ module.addHostAndDeviceProperties()
+ module.AddProperties(&module.binaryProperties)
module.Module.properties.Installable = proptools.BoolPtr(true)
@@ -2415,10 +2481,8 @@ func BinaryFactory() android.Module {
func BinaryHostFactory() android.Module {
module := &Binary{}
- module.AddProperties(
- &module.Module.properties,
- &module.Module.protoProperties,
- &module.binaryProperties)
+ module.addHostProperties()
+ module.AddProperties(&module.binaryProperties)
module.Module.properties.Installable = proptools.BoolPtr(true)
@@ -2617,6 +2681,11 @@ func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
return j.depIsInSameApex(ctx, dep)
}
+func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error {
+ // Do not check for prebuilts against the min_sdk_version of enclosing APEX
+ return nil
+}
+
// Add compile time check for interface implementation
var _ android.IDEInfo = (*Import)(nil)
var _ android.IDECustomizedModuleName = (*Import)(nil)
@@ -2723,6 +2792,10 @@ func (a *DexImport) JacocoReportClassesFile() android.Path {
return nil
}
+func (a *DexImport) LintDepSets() LintDepSets {
+ return LintDepSets{}
+}
+
func (j *DexImport) IsInstallable() bool {
return true
}
@@ -2786,6 +2859,11 @@ func (j *DexImport) DexJarBuildPath() android.Path {
return j.dexJarFile
}
+func (j *DexImport) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error {
+ // we don't check prebuilt modules for sdk_version
+ return nil
+}
+
// dex_import imports a `.jar` file containing classes.dex files.
//
// A dex_import module cannot be used as a dependency of a java_* or android_* module, it can only be installed
@@ -2851,6 +2929,7 @@ func DefaultsFactory() android.Module {
module.AddProperties(
&CompilerProperties{},
&CompilerDeviceProperties{},
+ &DexProperties{},
&DexpreoptProperties{},
&android.ProtoProperties{},
&aaptProperties{},
@@ -2858,6 +2937,7 @@ func DefaultsFactory() android.Module {
&appProperties{},
&appTestProperties{},
&overridableAppProperties{},
+ &testProperties{},
&ImportProperties{},
&AARImportProperties{},
&sdkLibraryProperties{},
@@ -2865,6 +2945,7 @@ func DefaultsFactory() android.Module {
&DexImportProperties{},
&android.ApexProperties{},
&RuntimeResourceOverlayProperties{},
+ &LintProperties{},
)
android.InitDefaultsModule(module)