Always run package check
Previously, the package check was only run when building checkbuild or
the phony target created for a specific module. It would not run when
building a module that depended upon a library with the
permitted_packages property. That was because the package check was
only run when the package-check.stamp file was built and that was only
added to the phony and checkbuild targets.
Instead of touching a separate package-check.stamp file to indicate
that the check has been performed this change copies the input jar file
to the package check to a separate ../package-check/<jar> file which is
then treated as the output of the library and is the input for any dex
processing. So, any modules that depend on this library will
transitively depend on the output file produced by the package check
command and so will ensure that the package check is always run.
Test: Removed "android.net" from the permitted_packages for
"framework-tethering", build "framework-tethering" which
triggered and failed the package check and
"com.android.tethering" which did not.
Made this change.
Built "com.android.tethering" which triggered and then failed the
package check.
Removed change to "framework-tethering"
Bug: 157649935
Change-Id: Ib01aa09e13f80282218049270eb7a58ec5f9f605
diff --git a/java/builder.go b/java/builder.go
index a27e5c3..640dba9 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -206,7 +206,7 @@
blueprint.RuleParams{
Command: "rm -f $out && " +
"${config.PackageCheckCmd} $in $packages && " +
- "touch $out",
+ "cp $in $out",
CommandDeps: []string{"${config.PackageCheckCmd}"},
},
"packages")
@@ -547,8 +547,9 @@
})
}
-func CheckJarPackages(ctx android.ModuleContext, outputFile android.WritablePath,
- classesJar android.Path, permittedPackages []string) {
+func CheckJarPackages(ctx android.ModuleContext, classesJar android.Path, permittedPackages []string) android.ModuleOutPath {
+ outputFile := android.PathForModuleOut(ctx, "package-check", classesJar.Base())
+
ctx.Build(pctx, android.BuildParams{
Rule: packageCheck,
Description: "packageCheck",
@@ -558,6 +559,8 @@
"packages": strings.Join(permittedPackages, " "),
},
})
+
+ return outputFile
}
func TransformJetifier(ctx android.ModuleContext, outputFile android.WritablePath,