apex respects stem of java_library modules
apex now respects stem of java_library modules.
As a follow-up we need to suppor the same for other types of modules.
Exempt-From-Owner-Approval: cherry-pick from AOSP
Bug: 157638999
Test: m
Merged-In: Iaf5023020b5440f1ffd4f5414b5a7864655fc22a
(cherry picked from commit a62aa2399031a01620775a06dbae53af0cff5a25)
Change-Id: Iaf5023020b5440f1ffd4f5414b5a7864655fc22a
diff --git a/apex/apex.go b/apex/apex.go
index 6ae6cd9..ba1c1d2 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1179,6 +1179,7 @@
// apexFile represents a file in an APEX bundle
type apexFile struct {
builtFile android.Path
+ stem string
moduleName string
installDir string
class apexFileClass
@@ -1218,9 +1219,17 @@
return af.builtFile != nil && af.builtFile.String() != ""
}
+func (af *apexFile) apexRelativePath(path string) string {
+ return filepath.Join(af.installDir, path)
+}
+
// Path() returns path of this apex file relative to the APEX root
func (af *apexFile) Path() string {
- return filepath.Join(af.installDir, af.builtFile.Base())
+ stem := af.builtFile.Base()
+ if af.stem != "" {
+ stem = af.stem
+ }
+ return af.apexRelativePath(stem)
}
// SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root
@@ -1660,11 +1669,17 @@
return af
}
-func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib java.Dependency, module android.Module) apexFile {
+type javaDependency interface {
+ java.Dependency
+ Stem() string
+}
+
+func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaDependency, module android.Module) apexFile {
dirInApex := "javalib"
fileToCopy := lib.DexJar()
af := newApexFile(ctx, fileToCopy, module.Name(), dirInApex, javaSharedLib, module)
af.jacocoReportClassesFile = lib.JacocoReportClassesFile()
+ af.stem = lib.Stem() + ".jar"
return af
}