Remove `exported_java_libs` from prebuilt_apex/apex_set module types
`exported_java_libs` provide information to soong about which .jars in a
prebuilt .apex need to be deapexed. This property is not used today,
since the only use case for deapexing is for dexpreopt, and dexpreopt is
done using bootjars (encapsulated using
`exported_bootclasspath_fragments`) and systemserver jars (encapsulated
using `exported_systemserverclasspath_fragments`)
Test: go test ./apex
Change-Id: I4ceec74aa11d8e32ccfb0bab29a4489cf8b3fc3d
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 685cb37..6f52653 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -4885,236 +4885,6 @@
func (ctx moduleErrorfTestCtx) ModuleErrorf(format string, args ...interface{}) {
}
-// These tests verify that the prebuilt_apex/deapexer to java_import wiring allows for the
-// propagation of paths to dex implementation jars from the former to the latter.
-func TestPrebuiltExportDexImplementationJars(t *testing.T) {
- transform := android.NullFixturePreparer
-
- checkDexJarBuildPath := func(t *testing.T, ctx *android.TestContext, name string) {
- t.Helper()
- // Make sure the import has been given the correct path to the dex jar.
- p := ctx.ModuleForTests(name, "android_common_myapex").Module().(java.UsesLibraryDependency)
- dexJarBuildPath := p.DexJarBuildPath(moduleErrorfTestCtx{}).PathOrNil()
- stem := android.RemoveOptionalPrebuiltPrefix(name)
- android.AssertStringEquals(t, "DexJarBuildPath should be apex-related path.",
- ".intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/"+stem+".jar",
- android.NormalizePathForTesting(dexJarBuildPath))
- }
-
- checkDexJarInstallPath := func(t *testing.T, ctx *android.TestContext, name string) {
- t.Helper()
- // Make sure the import has been given the correct path to the dex jar.
- p := ctx.ModuleForTests(name, "android_common_myapex").Module().(java.UsesLibraryDependency)
- dexJarBuildPath := p.DexJarInstallPath()
- stem := android.RemoveOptionalPrebuiltPrefix(name)
- android.AssertStringEquals(t, "DexJarInstallPath should be apex-related path.",
- "target/product/test_device/apex/myapex/javalib/"+stem+".jar",
- android.NormalizePathForTesting(dexJarBuildPath))
- }
-
- ensureNoSourceVariant := func(t *testing.T, ctx *android.TestContext, name string) {
- t.Helper()
- // Make sure that an apex variant is not created for the source module.
- android.AssertArrayString(t, "Check if there is no source variant",
- []string{"android_common"},
- ctx.ModuleVariantsForTests(name))
- }
-
- t.Run("prebuilt only", func(t *testing.T) {
- bp := `
- prebuilt_apex {
- name: "myapex",
- arch: {
- arm64: {
- src: "myapex-arm64.apex",
- },
- arm: {
- src: "myapex-arm.apex",
- },
- },
- exported_java_libs: ["libfoo", "libbar"],
- }
-
- java_import {
- name: "libfoo",
- jars: ["libfoo.jar"],
- sdk_version: "core_current",
- }
-
- java_sdk_library_import {
- name: "libbar",
- public: {
- jars: ["libbar.jar"],
- },
- }
- `
-
- // Make sure that dexpreopt can access dex implementation files from the prebuilt.
- ctx := testDexpreoptWithApexes(t, bp, "", transform)
-
- deapexerName := deapexerModuleName("prebuilt_myapex")
- android.AssertStringEquals(t, "APEX module name from deapexer name", "prebuilt_myapex", apexModuleName(deapexerName))
-
- // Make sure that the deapexer has the correct input APEX.
- deapexer := ctx.ModuleForTests(deapexerName, "android_common")
- rule := deapexer.Rule("deapexer")
- if expected, actual := []string{"myapex-arm64.apex"}, android.NormalizePathsForTesting(rule.Implicits); !reflect.DeepEqual(expected, actual) {
- t.Errorf("expected: %q, found: %q", expected, actual)
- }
-
- // Make sure that the prebuilt_apex has the correct input APEX.
- prebuiltApex := ctx.ModuleForTests("myapex", "android_common_myapex")
- rule = prebuiltApex.Rule("android/soong/android.Cp")
- if expected, actual := "myapex-arm64.apex", android.NormalizePathForTesting(rule.Input); !reflect.DeepEqual(expected, actual) {
- t.Errorf("expected: %q, found: %q", expected, actual)
- }
-
- checkDexJarBuildPath(t, ctx, "libfoo")
- checkDexJarInstallPath(t, ctx, "libfoo")
-
- checkDexJarBuildPath(t, ctx, "libbar")
- checkDexJarInstallPath(t, ctx, "libbar")
- })
-
- t.Run("prebuilt with source preferred", func(t *testing.T) {
-
- bp := `
- apex {
- name: "myapex",
- key: "myapex.key",
- updatable: false,
- java_libs: [
- "libfoo",
- "libbar",
- ],
- }
-
- apex_key {
- name: "myapex.key",
- public_key: "testkey.avbpubkey",
- private_key: "testkey.pem",
- }
-
- prebuilt_apex {
- name: "myapex",
- arch: {
- arm64: {
- src: "myapex-arm64.apex",
- },
- arm: {
- src: "myapex-arm.apex",
- },
- },
- exported_java_libs: ["libfoo", "libbar"],
- }
-
- java_import {
- name: "libfoo",
- jars: ["libfoo.jar"],
- apex_available: [
- "myapex",
- ],
- compile_dex: true,
- sdk_version: "core_current",
- }
-
- java_library {
- name: "libfoo",
- srcs: ["foo/bar/MyClass.java"],
- apex_available: [
- "myapex",
- ],
- compile_dex: true,
- sdk_version: "core_current",
- }
-
- java_sdk_library_import {
- name: "libbar",
- public: {
- jars: ["libbar.jar"],
- },
- apex_available: [
- "myapex",
- ],
- compile_dex: true,
- }
-
- java_sdk_library {
- name: "libbar",
- srcs: ["foo/bar/MyClass.java"],
- unsafe_ignore_missing_latest_api: true,
- apex_available: [
- "myapex",
- ],
- compile_dex: true,
- sdk_version: "core_current",
- }
- `
-
- // Make sure that dexpreopt can access dex implementation files from the prebuilt.
- ctx := testDexpreoptWithApexes(t, bp, "", transform)
-
- checkDexJarBuildPath(t, ctx, "prebuilt_libfoo")
- checkDexJarInstallPath(t, ctx, "prebuilt_libfoo")
-
- checkDexJarBuildPath(t, ctx, "prebuilt_libbar")
- checkDexJarInstallPath(t, ctx, "prebuilt_libbar")
- })
-
- t.Run("prebuilt preferred with source", func(t *testing.T) {
- bp := `
- prebuilt_apex {
- name: "myapex",
- arch: {
- arm64: {
- src: "myapex-arm64.apex",
- },
- arm: {
- src: "myapex-arm.apex",
- },
- },
- exported_java_libs: ["libfoo", "libbar"],
- }
-
- java_import {
- name: "libfoo",
- prefer: true,
- jars: ["libfoo.jar"],
- }
-
- java_library {
- name: "libfoo",
- sdk_version: "core_current",
- }
-
- java_sdk_library_import {
- name: "libbar",
- prefer: true,
- public: {
- jars: ["libbar.jar"],
- },
- }
-
- java_sdk_library {
- name: "libbar",
- srcs: ["foo/bar/MyClass.java"],
- unsafe_ignore_missing_latest_api: true,
- }
- `
-
- // Make sure that dexpreopt can access dex implementation files from the prebuilt.
- ctx := testDexpreoptWithApexes(t, bp, "", transform)
-
- checkDexJarBuildPath(t, ctx, "prebuilt_libfoo")
- checkDexJarInstallPath(t, ctx, "prebuilt_libfoo")
- ensureNoSourceVariant(t, ctx, "libfoo")
-
- checkDexJarBuildPath(t, ctx, "prebuilt_libbar")
- checkDexJarInstallPath(t, ctx, "prebuilt_libbar")
- ensureNoSourceVariant(t, ctx, "libbar")
- })
-}
-
func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
preparer := android.GroupFixturePreparers(
java.FixtureConfigureApexBootJars("myapex:libfoo", "myapex:libbar"),
@@ -5243,18 +5013,10 @@
apex_set {
name: "myapex",
set: "myapex.apks",
- exported_java_libs: ["myjavalib"],
exported_bootclasspath_fragments: ["my-bootclasspath-fragment"],
exported_systemserverclasspath_fragments: ["my-systemserverclasspath-fragment"],
}
- java_import {
- name: "myjavalib",
- jars: ["myjavalib.jar"],
- apex_available: ["myapex"],
- permitted_packages: ["javalib"],
- }
-
prebuilt_bootclasspath_fragment {
name: "my-bootclasspath-fragment",
contents: ["libfoo", "libbar"],
@@ -9618,42 +9380,6 @@
ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := foo.myapex foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.odex foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.vdex\n")
}
-func TestAndroidMk_DexpreoptBuiltInstalledForApex_Prebuilt(t *testing.T) {
- ctx := testApex(t, `
- prebuilt_apex {
- name: "myapex",
- arch: {
- arm64: {
- src: "myapex-arm64.apex",
- },
- arm: {
- src: "myapex-arm.apex",
- },
- },
- exported_java_libs: ["foo"],
- }
-
- java_import {
- name: "foo",
- jars: ["foo.jar"],
- apex_available: ["myapex"],
- }
- `,
- dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"),
- )
-
- prebuilt := ctx.ModuleForTests("myapex", "android_common_myapex").Module().(*Prebuilt)
- entriesList := android.AndroidMkEntriesForTest(t, ctx, prebuilt)
- mainModuleEntries := entriesList[0]
- android.AssertArrayString(t,
- "LOCAL_REQUIRED_MODULES",
- mainModuleEntries.EntryMap["LOCAL_REQUIRED_MODULES"],
- []string{
- "foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.odex",
- "foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.vdex",
- })
-}
-
func TestAndroidMk_RequiredModules(t *testing.T) {
ctx := testApex(t, `
apex {
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index f1a134e..2e5662d 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -107,11 +107,6 @@
// from PRODUCT_PACKAGES.
Overrides []string
- // List of java libraries that are embedded inside this prebuilt APEX bundle and for which this
- // APEX bundle will create an APEX variant and provide dex implementation jars for use by
- // dexpreopt and boot jars package check.
- Exported_java_libs []string
-
// List of bootclasspath fragments inside this prebuilt APEX bundle and for which this APEX
// bundle will create an APEX variant.
Exported_bootclasspath_fragments []string
@@ -283,8 +278,7 @@
}
func (p *prebuiltCommon) hasExportedDeps() bool {
- return len(p.prebuiltCommonProperties.Exported_java_libs) > 0 ||
- len(p.prebuiltCommonProperties.Exported_bootclasspath_fragments) > 0 ||
+ return len(p.prebuiltCommonProperties.Exported_bootclasspath_fragments) > 0 ||
len(p.prebuiltCommonProperties.Exported_systemserverclasspath_fragments) > 0
}
@@ -292,11 +286,6 @@
func (p *prebuiltCommon) prebuiltApexContentsDeps(ctx android.BottomUpMutatorContext) {
module := ctx.Module()
- for _, dep := range p.prebuiltCommonProperties.Exported_java_libs {
- prebuiltDep := android.PrebuiltNameFromSource(dep)
- ctx.AddDependency(module, exportedJavaLibTag, prebuiltDep)
- }
-
for _, dep := range p.prebuiltCommonProperties.Exported_bootclasspath_fragments {
prebuiltDep := android.PrebuiltNameFromSource(dep)
ctx.AddDependency(module, exportedBootclasspathFragmentTag, prebuiltDep)
@@ -559,7 +548,7 @@
// createDeapexerModuleIfNeeded will create a deapexer module if it is needed.
//
// A deapexer module is only needed when the prebuilt apex specifies one or more modules in either
-// the `exported_java_libs` or `exported_bootclasspath_fragments` properties as that indicates that
+// the `exported_bootclasspath_fragments` properties as that indicates that
// the listed modules need access to files from within the prebuilt .apex file.
func (p *prebuiltCommon) createDeapexerModuleIfNeeded(ctx android.TopDownMutatorContext, deapexerName string, apexFileSource string) {
// Only create the deapexer module if it is needed.
@@ -666,7 +655,6 @@
var _ android.RequiresFilesFromPrebuiltApexTag = exportedDependencyTag{}
var (
- exportedJavaLibTag = exportedDependencyTag{name: "exported_java_libs"}
exportedBootclasspathFragmentTag = exportedDependencyTag{name: "exported_bootclasspath_fragments"}
exportedSystemserverclasspathFragmentTag = exportedDependencyTag{name: "exported_systemserverclasspath_fragments"}
)
@@ -677,7 +665,7 @@
// build.
//
// If this needs to make files from within a `.apex` file available for use by other Soong modules,
-// e.g. make dex implementation jars available for java_import modules listed in exported_java_libs,
+// e.g. make dex implementation jars available for `contents` listed in exported_bootclasspath_fragments,
// it does so as follows:
//
// 1. It creates a `deapexer` module that actually extracts the files from the `.apex` file and