Get dex jar resources from classpath jar

Dex jars were getting their resources from the res.jar files of
their transitive static dependencies.  This accidentally bypassed
jarjar on resources, since the jarjar pass only happened once the
resources jar was combined into the classpath jar.  Switch to
getting the resources out of the classpath jar by merging it
with the dex jar while skipping *.class.

Test: m -j checkbuild
Test: compare ext.jar to one generated by make
Change-Id: I5f6f3da738dcb0af56ab9a1bd7174ed5359de2b2
diff --git a/java/builder.go b/java/builder.go
index b924d65..ca0d2c5 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -99,10 +99,12 @@
 		blueprint.RuleParams{
 			Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
 				`${config.DxCmd} --dex --output=$outDir $dxFlags $in && ` +
-				`${config.SoongZipCmd} -jar -o $out -C $outDir -D $outDir`,
+				`${config.SoongZipCmd} -o $outDir/classes.dex.jar -C $outDir -D $outDir && ` +
+				`${config.MergeZipsCmd} -D -stripFile "*.class" $out $outDir/classes.dex.jar $in`,
 			CommandDeps: []string{
 				"${config.DxCmd}",
 				"${config.SoongZipCmd}",
+				"${config.MergeZipsCmd}",
 			},
 		},
 		"outDir", "dxFlags")
@@ -298,11 +300,13 @@
 	return outputFile
 }
 
-func TransformClassesJarToDexJar(ctx android.ModuleContext, classesJar android.Path,
+// Converts a classes.jar file to classes*.dex, then combines the dex files with any resources
+// in the classes.jar file into a dex jar.
+func TransformClassesJarToDexJar(ctx android.ModuleContext, stem string, classesJar android.Path,
 	flags javaBuilderFlags) android.Path {
 
 	outDir := android.PathForModuleOut(ctx, "dex")
-	outputFile := android.PathForModuleOut(ctx, "classes.dex.jar")
+	outputFile := android.PathForModuleOut(ctx, stem)
 
 	ctx.ModuleBuild(pctx, android.ModuleBuildParams{
 		Rule:        dx,