Add jarjar support
If jarjar_rules is set, pass the compiled jar through jarjar to
produce a new intermediate jar.
Change-Id: Ied596433fd5c49d05f07c04245f3abe8b9aadc5e
diff --git a/java/builder.go b/java/builder.go
index 2c72cab..f0cfeae 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -62,6 +62,13 @@
},
"outDir", "dxFlags")
+ jarjar = pctx.StaticRule("jarjar",
+ blueprint.RuleParams{
+ Command: "java -jar $jarjarCmd process $rulesFile $in $out",
+ Description: "jarjar $out",
+ },
+ "rulesFile")
+
extractPrebuilt = pctx.StaticRule("extractPrebuilt",
blueprint.RuleParams{
Command: `rm -rf $outDir && unzip -qo $in -d $outDir && ` +
@@ -80,6 +87,9 @@
pctx.VariableFunc("dxCmd", func(c interface{}) (string, error) {
return c.(Config).HostBinTool("dx")
})
+ pctx.VariableFunc("jarjarCmd", func(c interface{}) (string, error) {
+ return c.(Config).HostJavaTool("jarjar.jar")
+ })
}
type javaBuilderFlags struct {
@@ -198,6 +208,21 @@
return outputFile
}
+func TransformJarJar(ctx common.AndroidModuleContext, classesJar string, rulesFile string) string {
+ outputFile := filepath.Join(common.ModuleOutDir(ctx), "classes-jarjar.jar")
+ ctx.Build(pctx, blueprint.BuildParams{
+ Rule: jarjar,
+ Outputs: []string{outputFile},
+ Inputs: []string{classesJar},
+ Implicits: []string{"$jarjarCmd"},
+ Args: map[string]string{
+ "rulesFile": rulesFile,
+ },
+ })
+
+ return outputFile
+}
+
func TransformPrebuiltJarToClasses(ctx common.AndroidModuleContext,
prebuilt string) (classJarSpec, resourceJarSpec jarSpec) {