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/java.go b/java/java.go
index 8b7e02d..f934721 100644
--- a/java/java.go
+++ b/java/java.go
@@ -33,6 +33,7 @@
 	SrcDir() string
 	PrebuiltOS() string
 	HostBinTool(string) (string, error)
+	HostJavaTool(string) (string, error)
 	Getenv(string) string
 }
 
@@ -90,6 +91,9 @@
 		// Set for device java libraries, and for host versions of device java libraries
 		// built for testing
 		Dex bool `blueprint:"mutated"`
+
+		// jarjar_rules: if not blank, run jarjar using the specified rules file
+		Jarjar_rules string
 	}
 
 	// output file suitable for inserting into the classpath of another compile
@@ -235,8 +239,19 @@
 	if ctx.Failed() {
 		return
 	}
+
 	j.classJarSpecs = classJarSpecs
 	j.resourceJarSpecs = resourceJarSpecs
+
+	if j.properties.Jarjar_rules != "" {
+		jarjar_rules := filepath.Join(common.ModuleSrcDir(ctx), j.properties.Jarjar_rules)
+		// Transform classes-full-debug.jar into classes-jarjar.jar
+		outputFile = TransformJarJar(ctx, outputFile, jarjar_rules)
+		if ctx.Failed() {
+			return
+		}
+	}
+
 	j.classpathFile = outputFile
 
 	if j.properties.Dex {