From 034196d9fe85d0c492c52dc9c89b4c9ddad1498e Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 17 Jun 2021 15:59:07 +0100 Subject: Simplify deapexer support Uses the apex relative path to the file as the identifier that is used to obtain the path to the corresponding file extracted from the apex. That is instead of a special constructed string id. Bug: 177892522 Test: m nothing Merged-In: I5dc77c8fb272bac289b8891d1eac801e541af1f5 Change-Id: I5dc77c8fb272bac289b8891d1eac801e541af1f5 (cherry picked from commit b4bbf2ca10cc8509e3ae0ab104e9e3b55861831b) --- java/java.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'java/java.go') diff --git a/java/java.go b/java/java.go index 3b6c9c884..ae8adf277 100644 --- a/java/java.go +++ b/java/java.go @@ -1309,7 +1309,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { // Get the path of the dex implementation jar from the `deapexer` module. di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo) - if dexOutputPath := di.PrebuiltExportPath(j.BaseModuleName(), ".dexjar"); dexOutputPath != nil { + if dexOutputPath := di.PrebuiltExportPath(apexRootRelativePathToJavaLib(j.BaseModuleName())); dexOutputPath != nil { j.dexJarFile = dexOutputPath // Initialize the hiddenapi structure. @@ -1429,17 +1429,22 @@ func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext, // requiredFilesFromPrebuiltApexForImport returns information about the files that a java_import or // java_sdk_library_import with the specified base module name requires to be exported from a // prebuilt_apex/apex_set. -func requiredFilesFromPrebuiltApexForImport(name string) map[string]string { - // Add the dex implementation jar to the set of exported files. The path here must match the - // path of the file in the APEX created by apexFileForJavaModule(...). - return map[string]string{ - name + "{.dexjar}": filepath.Join("javalib", name+".jar"), +func requiredFilesFromPrebuiltApexForImport(name string) []string { + // Add the dex implementation jar to the set of exported files. + return []string{ + apexRootRelativePathToJavaLib(name), } } +// apexRootRelativePathToJavaLib returns the path, relative to the root of the apex's contents, for +// the java library with the specified name. +func apexRootRelativePathToJavaLib(name string) string { + return filepath.Join("javalib", name+".jar") +} + var _ android.RequiredFilesFromPrebuiltApex = (*Import)(nil) -func (j *Import) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) map[string]string { +func (j *Import) RequiredFilesFromPrebuiltApex(_ android.BaseModuleContext) []string { name := j.BaseModuleName() return requiredFilesFromPrebuiltApexForImport(name) } -- cgit v1.2.3