Merge libs/ directory of imported aars into classes.jar
AARs can provide extra classes in the libs/ directory that should
be treated the same as classes.jar, merge them into a single jar
when extracting the AAR.
Bug: 162892721
Test: m androidx.appsearch_appsearch
Change-Id: I92bf46f47ce5f3dce16c42197c15ed256304fda2
diff --git a/java/aar.go b/java/aar.go
index ad9b5e7..cbb6248 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -641,9 +641,11 @@
var unzipAAR = pctx.AndroidStaticRule("unzipAAR",
blueprint.RuleParams{
Command: `rm -rf $outDir && mkdir -p $outDir && ` +
- `unzip -qoDD -d $outDir $in && rm -rf $outDir/res && touch $out`,
+ `unzip -qoDD -d $outDir $in && rm -rf $outDir/res && touch $out && ` +
+ `${config.MergeZipsCmd} $combinedClassesJar $$(ls $outDir/classes.jar 2> /dev/null) $$(ls $outDir/libs/*.jar 2> /dev/null)`,
+ CommandDeps: []string{"${config.MergeZipsCmd}"},
},
- "outDir")
+ "outDir", "combinedClassesJar")
func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if len(a.properties.Aars) != 1 {
@@ -661,7 +663,7 @@
}
extractedAARDir := android.PathForModuleOut(ctx, "aar")
- a.classpathFile = extractedAARDir.Join(ctx, "classes.jar")
+ a.classpathFile = extractedAARDir.Join(ctx, "classes-combined.jar")
a.proguardFlags = extractedAARDir.Join(ctx, "proguard.txt")
a.manifest = extractedAARDir.Join(ctx, "AndroidManifest.xml")
@@ -671,7 +673,8 @@
Outputs: android.WritablePaths{a.classpathFile, a.proguardFlags, a.manifest},
Description: "unzip AAR",
Args: map[string]string{
- "outDir": extractedAARDir.String(),
+ "outDir": extractedAARDir.String(),
+ "combinedClassesJar": a.classpathFile.String(),
},
})