Revert^2 "Remove compilation actions from java sdk library"
This change modifies the build actions of java_sdk_library module type
so that it does not perform any compilation actions (i.e. does not
create the top level java_sdk_library jar file). Instead, it delegates
the build actions the top level jar file was performing to the
dynamically created ".impl"-suffixed java library module. The build
actions that are delegated to the impl library module include hiddenapi
processing, dexing, and dexpreopt.
This change relands https://r.android.com/3035972. Implementation
changes from the original change:
- "all_apex_contributions" is added as a dependecy to the implementation
library modules where the parent sdk_library module has a prebuilt
equivalent. This allows the source apex variant to be hidden from make
when the prebuilt is active.
Test: patch in internal main, lunch barbet-ap2a-userdebug && m nothing
Test: m nothing --no-skip-soong-tests
Bug: 332785297
Change-Id: I017938e5567aef82e428e7ceb557d9c9090e0257
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 5fac255..1c94a8a 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -186,13 +186,13 @@
// test if quuz have created the api_contribution module
result.ModuleForTests(apiScopePublic.stubsSourceModuleName("quuz")+".api.contribution", "")
- fooDexJar := result.ModuleForTests("foo", "android_common").Rule("d8")
- // tests if kotlinc generated files are NOT excluded from output of foo.
- android.AssertStringDoesNotContain(t, "foo dex", fooDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module")
+ fooImplDexJar := result.ModuleForTests("foo.impl", "android_common").Rule("d8")
+ // tests if kotlinc generated files are NOT excluded from output of foo.impl.
+ android.AssertStringDoesNotContain(t, "foo.impl dex", fooImplDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module")
- barDexJar := result.ModuleForTests("bar", "android_common").Rule("d8")
- // tests if kotlinc generated files are excluded from output of bar.
- android.AssertStringDoesContain(t, "bar dex", barDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module")
+ barImplDexJar := result.ModuleForTests("bar.impl", "android_common").Rule("d8")
+ // tests if kotlinc generated files are excluded from output of bar.impl.
+ android.AssertStringDoesContain(t, "bar.impl dex", barImplDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module")
}
func TestJavaSdkLibrary_UpdatableLibrary(t *testing.T) {
@@ -1469,11 +1469,11 @@
preparer.RunTestWithBp(t, `
java_sdk_library {
name: "sdklib",
- srcs: ["a.java"],
- static_libs: ["util"],
- min_sdk_version: "30",
+ srcs: ["a.java"],
+ static_libs: ["util"],
+ min_sdk_version: "30",
unsafe_ignore_missing_latest_api: true,
- }
+ }
java_library {
name: "util",