diff --git a/apex/androidmk.go b/apex/androidmk.go index 811bc426e..cbff7f4f4 100644 --- a/apex/androidmk.go +++ b/apex/androidmk.go @@ -171,7 +171,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo // we need to remove the suffix from LOCAL_MODULE_STEM, otherwise // we will have foo.jar.jar fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.Stem(), ".jar")) - if javaModule, ok := fi.module.(java.Dependency); ok { + if javaModule, ok := fi.module.(java.ApexDependency); ok { fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", javaModule.ImplementationAndResourcesJars()[0].String()) fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", javaModule.HeaderJars()[0].String()) } else { diff --git a/apex/apex.go b/apex/apex.go index 387b29b14..994a05176 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1685,7 +1685,9 @@ type javaDependency interface { 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) + // Remove prebuilt_ if necessary so the source and prebuilt modules have the same name. + name := strings.TrimPrefix(module.Name(), "prebuilt_") + af := newApexFile(ctx, fileToCopy, name, dirInApex, javaSharedLib, module) af.jacocoReportClassesFile = lib.JacocoReportClassesFile() af.stem = lib.Stem() + ".jar" return af diff --git a/java/java.go b/java/java.go index 9e196f43d..90e9b1f6f 100644 --- a/java/java.go +++ b/java/java.go @@ -517,11 +517,16 @@ func (j *Module) OutputFiles(tag string) (android.Paths, error) { var _ android.OutputFileProducer = (*Module)(nil) -type Dependency interface { +// Methods that need to be implemented for a module that is added to apex java_libs property. +type ApexDependency interface { HeaderJars() android.Paths + ImplementationAndResourcesJars() android.Paths +} + +type Dependency interface { + ApexDependency ImplementationJars() android.Paths ResourceJars() android.Paths - ImplementationAndResourcesJars() android.Paths DexJar() android.Path AidlIncludeDirs() android.Paths ExportedSdkLibs() []string diff --git a/java/sdk_library.go b/java/sdk_library.go index 8e9c0774e..f000af91e 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -2005,6 +2005,26 @@ func (module *SdkLibraryImport) Stem() string { return module.BaseModuleName() } +var _ ApexDependency = (*SdkLibraryImport)(nil) + +// to satisfy java.ApexDependency interface +func (module *SdkLibraryImport) HeaderJars() android.Paths { + if module.implLibraryModule == nil { + return nil + } else { + return module.implLibraryModule.HeaderJars() + } +} + +// to satisfy java.ApexDependency interface +func (module *SdkLibraryImport) ImplementationAndResourcesJars() android.Paths { + if module.implLibraryModule == nil { + return nil + } else { + return module.implLibraryModule.ImplementationAndResourcesJars() + } +} + // // java_sdk_library_xml //