Strip relative paths from android_library_import output files
androidx.annotation_annotation is used as a test data file, and
converting it from an android_library to an android_library_import
causes the relative path used in the test data path to change.
Clear the relative path in android_library_import the same way that
android_library and other java based modules do.
Also change the name of classes-combined.jar to the name of the
module so that the output file has the right name if there are no
static dependences that require running the merge_zips step.
Bug: 288358614
Test: TestAndroidLibraryOutputFileRel
Change-Id: I28210aa370a742d789102ff71db3685ca744878f
diff --git a/java/aar.go b/java/aar.go
index 1734da9..5a478d0 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -1154,7 +1154,7 @@
}
extractedAARDir := android.PathForModuleOut(ctx, "aar")
- classpathFile := extractedAARDir.Join(ctx, "classes-combined.jar")
+ classpathFile := extractedAARDir.Join(ctx, ctx.ModuleName()+".jar")
a.manifest = extractedAARDir.Join(ctx, "AndroidManifest.xml")
a.rTxt = extractedAARDir.Join(ctx, "R.txt")
a.assetsPackage = android.PathForModuleOut(ctx, "assets.zip")
@@ -1276,14 +1276,18 @@
addCLCFromDep(ctx, module, a.classLoaderContexts)
})
+ var implementationJarFile android.OutputPath
if len(staticJars) > 0 {
combineJars := append(android.Paths{classpathFile}, staticJars...)
- a.implementationJarFile = android.PathForModuleOut(ctx, "combined", ctx.ModuleName()+".jar")
- TransformJarsToJar(ctx, a.implementationJarFile, "combine", combineJars, android.OptionalPath{}, false, nil, nil)
+ implementationJarFile = android.PathForModuleOut(ctx, "combined", ctx.ModuleName()+".jar").OutputPath
+ TransformJarsToJar(ctx, implementationJarFile, "combine", combineJars, android.OptionalPath{}, false, nil, nil)
} else {
- a.implementationJarFile = classpathFile
+ implementationJarFile = classpathFile
}
+ // Save the output file with no relative path so that it doesn't end up in a subdirectory when used as a resource
+ a.implementationJarFile = implementationJarFile.WithoutRel()
+
if len(staticHeaderJars) > 0 {
combineJars := append(android.Paths{classpathFile}, staticHeaderJars...)
a.headerJarFile = android.PathForModuleOut(ctx, "turbine-combined", ctx.ModuleName()+".jar")