Touch up manifest if there's no source code.
The new package manager behavior requires packages without source code
to have an application element with hasCode attribute set to false in
their manifest. With this change, Soong can now automatically insert one
for codeless apps.
Test: app_test.go, manifest_fixer_test.py
Fixes: 124375490
Change-Id: Ied89a8d07c63805ab910859a4f7c45fc1c60bb73
diff --git a/java/java.go b/java/java.go
index 31c6afe..41e21b1 100644
--- a/java/java.go
+++ b/java/java.go
@@ -966,8 +966,6 @@
func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
- hasSrcs := false
-
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs)
deps := j.collectDeps(ctx)
@@ -982,9 +980,6 @@
}
srcFiles = j.genSources(ctx, srcFiles, flags)
- if len(srcFiles) > 0 {
- hasSrcs = true
- }
srcJars := srcFiles.FilterByExt(".srcjar")
srcJars = append(srcJars, deps.srcJars...)
@@ -1181,7 +1176,6 @@
if len(deps.staticJars) > 0 {
jars = append(jars, deps.staticJars...)
- hasSrcs = true
}
manifest := j.overrideManifest
@@ -1293,7 +1287,7 @@
j.implementationAndResourcesJar = implementationAndResourcesJar
- if ctx.Device() && hasSrcs &&
+ if ctx.Device() && j.hasCode(ctx) &&
(Bool(j.properties.Installable) || Bool(j.deviceProperties.Compile_dex)) {
// Dex compilation
var dexOutputFile android.ModuleOutPath
@@ -1498,6 +1492,11 @@
return jdeps
}
+func (j *Module) hasCode(ctx android.ModuleContext) bool {
+ srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
+ return len(srcFiles) > 0 || len(ctx.GetDirectDepsWithTag(staticLibTag)) > 0
+}
+
//
// Java libraries (.jar file)
//