Mechanism to select a specific version of java_sdk_library_import
This CL is the java_sdk_library_import equivalent of aosp/2928483.
With trunk stable, we will have multiple apex prebuilts in the tree.
Each apex prebuilt will have its own module sdk. This means that it is
possible to have mutliple versions of `framework-foo` in the tree. This
CL introduces a mechanism to select a specific versioned
java_sdk_library prebuilt.
Implementation details
- Add a `source_module_name` property to java_sdk_library_import. This
will identify the source equivalent of the jsl in packages/modules.
This used to be implicit - i.e. the name without the prebuilt_ prefix.
With multiple prebuilts, this has to become explicit.
- Set appropriate `source_module_name`(s) in the dynamically created
child modules. e.g. the source_module_name on sdklib.v1.stubs and
sdklib.v2.stubs will both be sdklib.stubs, assuming
`source_module_name` on the top-level jsl_import is sdklib
- Add a private Created_by_java_sdk_library_name property to java_import
and prebuilt_stubs_sources modules. This will be used to idenfity the
top level java_sdk_library_import that was used to create these child
modules. This is necessary because java_sdk_library_imoprt is a macro
that creates 1:many modules. However, to avoid toil, only the
top-level java_sdk_library_import will be listed in
`apex_contributions`. This new property will be used for
source/prebuilt selection in android/prebuuilt.go
- Rename BaseModuleName in commonSdkLibraryAndImportModule to
RootLibraryName. This is necesssary because the former is now reserved
to identify the source equivalent of a prebuilt module (maybe we
should rename it?)
Bug: 322175508
Test: Added a unit test
Change-Id: If6aa6b0e939a07f8263874941413908383c81a78
diff --git a/java/java.go b/java/java.go
index cd249ed..642e25b 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2095,6 +2095,11 @@
// If unspecified, follows the naming convention that the source module of
// the prebuilt is Name() without "prebuilt_" prefix
Source_module_name *string
+
+ // Non-nil if this java_import module was dynamically created by a java_sdk_library_import
+ // The name is the undecorated name of the java_sdk_library as it appears in the blueprint file
+ // (without any prebuilt_ prefix)
+ Created_by_java_sdk_library_name *string `blueprint:"mutated"`
}
type Import struct {
@@ -2180,6 +2185,10 @@
return proptools.StringDefault(j.properties.Stem, j.BaseModuleName())
}
+func (j *Import) CreatedByJavaSdkLibraryName() *string {
+ return j.properties.Created_by_java_sdk_library_name
+}
+
func (a *Import) JacocoReportClassesFile() android.Path {
return nil
}
@@ -2831,7 +2840,20 @@
type JavaApiContributionImport struct {
JavaApiContribution
- prebuilt android.Prebuilt
+ prebuilt android.Prebuilt
+ prebuiltProperties javaApiContributionImportProperties
+}
+
+type javaApiContributionImportProperties struct {
+ // Name of the source soong module that gets shadowed by this prebuilt
+ // If unspecified, follows the naming convention that the source module of
+ // the prebuilt is Name() without "prebuilt_" prefix
+ Source_module_name *string
+
+ // Non-nil if this java_import module was dynamically created by a java_sdk_library_import
+ // The name is the undecorated name of the java_sdk_library as it appears in the blueprint file
+ // (without any prebuilt_ prefix)
+ Created_by_java_sdk_library_name *string `blueprint:"mutated"`
}
func ApiContributionImportFactory() android.Module {
@@ -2839,7 +2861,7 @@
android.InitAndroidModule(module)
android.InitDefaultableModule(module)
android.InitPrebuiltModule(module, &[]string{""})
- module.AddProperties(&module.properties)
+ module.AddProperties(&module.properties, &module.prebuiltProperties)
module.AddProperties(&module.sdkLibraryComponentProperties)
return module
}
@@ -2852,6 +2874,14 @@
return module.prebuilt.Name(module.ModuleBase.Name())
}
+func (j *JavaApiContributionImport) BaseModuleName() string {
+ return proptools.StringDefault(j.prebuiltProperties.Source_module_name, j.ModuleBase.Name())
+}
+
+func (j *JavaApiContributionImport) CreatedByJavaSdkLibraryName() *string {
+ return j.prebuiltProperties.Created_by_java_sdk_library_name
+}
+
func (ap *JavaApiContributionImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ap.JavaApiContribution.GenerateAndroidBuildActions(ctx)
}