From 7db5d6332fac9c24345e37d467bef957ac3c85dd Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 4 Oct 2017 17:07:09 -0700 Subject: 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 --- java/java.go | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) (limited to 'java/java.go') diff --git a/java/java.go b/java/java.go index 9cde82408..3726435e9 100644 --- a/java/java.go +++ b/java/java.go @@ -153,9 +153,6 @@ type Module struct { // output file containing classes.dex dexJarFile android.Path - // output files containing resources - resourceJarFiles android.Paths - // output file suitable for installing or running outputFile android.Path @@ -173,7 +170,6 @@ type Module struct { type Dependency interface { ClasspathFiles() android.Paths - ResourceJarFiles() android.Paths AidlIncludeDirs() android.Paths } @@ -380,7 +376,6 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { case staticLibTag: deps.classpath = append(deps.classpath, dep.ClasspathFiles()...) deps.staticJars = append(deps.staticJars, dep.ClasspathFiles()...) - deps.staticJarResources = append(deps.staticJarResources, dep.ResourceJarFiles()...) case frameworkResTag: if ctx.ModuleName() == "framework" { // framework.jar has a one-off dependency on the R.java and Manifest.java files @@ -492,20 +487,14 @@ func (j *Module) compile(ctx android.ModuleContext) { } if len(resArgs) > 0 { - // Combine classes + resources into classes-full-debug.jar resourceJar := TransformResourcesToJar(ctx, resArgs, resDeps) if ctx.Failed() { return } - j.resourceJarFiles = append(j.resourceJarFiles, resourceJar) jars = append(jars, resourceJar) } - // Propagate the resources from the transitive closure of static dependencies for copying - // into dex jars - j.resourceJarFiles = append(j.resourceJarFiles, deps.staticJarResources...) - // static classpath jars have the resources in them, so the resource jars aren't necessary here jars = append(jars, deps.staticJars...) @@ -580,17 +569,12 @@ func (j *Module) compile(ctx android.ModuleContext) { return } - // Compile classes.jar into classes.dex - dexJarFile := TransformClassesJarToDexJar(ctx, desugarJar, flags) + // Compile classes.jar into classes.dex and then javalib.jar + outputFile = TransformClassesJarToDexJar(ctx, "javalib.jar", desugarJar, flags) if ctx.Failed() { return } - jars := android.Paths{dexJarFile} - jars = append(jars, j.resourceJarFiles...) - - outputFile = TransformJarsToJar(ctx, "javalib.jar", jars, android.OptionalPath{}, true) - j.dexJarFile = outputFile } ctx.CheckbuildFile(outputFile) @@ -607,10 +591,6 @@ func (j *Module) ClasspathFiles() android.Paths { return android.Paths{j.classpathFile} } -func (j *Module) ResourceJarFiles() android.Paths { - return j.resourceJarFiles -} - func (j *Module) AidlIncludeDirs() android.Paths { return j.exportAidlIncludeDirs } @@ -777,11 +757,6 @@ func (j *Import) ClasspathFiles() android.Paths { return j.classpathFiles } -func (j *Import) ResourceJarFiles() android.Paths { - // resources are in the ClasspathFiles - return nil -} - func (j *Import) AidlIncludeDirs() android.Paths { return nil } -- cgit v1.2.3-59-g8ed1b