Revert "Enable from-text stub generation in non-sdk java_sdk_library"
Revert submission 2982300-java_api_library_non_sdk
Reason for revert: DroidMonitor: Potential culprit for b/357648959 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.
Reverted changes: /q/submissionid:2982300-java_api_library_non_sdk
Change-Id: I5ef7afd9ec3e10ea99f82d02172843ad9b2cfda9
diff --git a/java/java_test.go b/java/java_test.go
index 2d4fca2..33079f3 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -1342,12 +1342,12 @@
}
`)
- checkBootClasspathForLibWithSystemModule(t, ctx, "lib-with-source-system-modules", "/source-jar.jar")
+ checkBootClasspathForSystemModule(t, ctx, "lib-with-source-system-modules", "/source-jar.jar")
- checkBootClasspathForLibWithSystemModule(t, ctx, "lib-with-prebuilt-system-modules", "/prebuilt-jar.jar")
+ checkBootClasspathForSystemModule(t, ctx, "lib-with-prebuilt-system-modules", "/prebuilt-jar.jar")
}
-func checkBootClasspathForLibWithSystemModule(t *testing.T, ctx *android.TestContext, moduleName string, expectedSuffix string) {
+func checkBootClasspathForSystemModule(t *testing.T, ctx *android.TestContext, moduleName string, expectedSuffix string) {
javacRule := ctx.ModuleForTests(moduleName, "android_common").Rule("javac")
bootClasspath := javacRule.Args["bootClasspath"]
if strings.HasPrefix(bootClasspath, "--system ") && strings.HasSuffix(bootClasspath, expectedSuffix) {
@@ -2256,6 +2256,61 @@
}
}
+func TestJavaApiLibraryFullApiSurfaceStub(t *testing.T) {
+ provider_bp_a := `
+ java_api_contribution {
+ name: "foo1",
+ api_file: "current.txt",
+ api_surface: "public",
+ }
+ `
+ provider_bp_b := `
+ java_api_contribution {
+ name: "foo2",
+ api_file: "current.txt",
+ api_surface: "public",
+ }
+ `
+ lib_bp_a := `
+ java_api_library {
+ name: "lib1",
+ api_surface: "public",
+ api_contributions: ["foo1", "foo2"],
+ stubs_type: "everything",
+ }
+ `
+
+ ctx := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ android.FixtureMergeMockFs(
+ map[string][]byte{
+ "a/Android.bp": []byte(provider_bp_a),
+ "b/Android.bp": []byte(provider_bp_b),
+ "c/Android.bp": []byte(lib_bp_a),
+ },
+ ),
+ android.FixtureMergeEnv(
+ map[string]string{
+ "DISABLE_STUB_VALIDATION": "true",
+ },
+ ),
+ ).RunTestWithBp(t, `
+ java_api_library {
+ name: "bar1",
+ api_surface: "public",
+ api_contributions: ["foo1"],
+ full_api_surface_stub: "lib1",
+ stubs_type: "everything",
+ }
+ `)
+
+ m := ctx.ModuleForTests("bar1", "android_common")
+ manifest := m.Output("metalava.sbox.textproto")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx.TestContext, manifest)
+ manifestCommand := sboxProto.Commands[0].GetCommand()
+ android.AssertStringDoesContain(t, "Command expected to contain full_api_surface_stub output jar", manifestCommand, "lib1.jar")
+}
+
func TestTransitiveSrcFiles(t *testing.T) {
ctx, _ := testJava(t, `
java_library {
@@ -2456,6 +2511,9 @@
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo"),
+ android.FixtureModifyConfig(func(config android.Config) {
+ config.SetApiLibraries([]string{"foo"})
+ }),
android.FixtureMergeMockFs(
map[string][]byte{
"A.java": nil,
@@ -2476,8 +2534,12 @@
system_modules: "baz",
}
`)
-
- checkBootClasspathForLibWithSystemModule(t, result.TestContext, apiScopePublic.apiLibraryModuleName("foo"), "/bar.jar")
+ m := result.ModuleForTests(apiScopePublic.apiLibraryModuleName("foo"), "android_common")
+ manifest := m.Output("metalava.sbox.textproto")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest)
+ manifestCommand := sboxProto.Commands[0].GetCommand()
+ classPathFlag := "--classpath __SBOX_SANDBOX_DIR__/out/soong/.intermediates/bar/android_common/turbine-combined/bar.jar"
+ android.AssertStringDoesContain(t, "command expected to contain classpath flag", manifestCommand, classPathFlag)
}
func TestApiLibraryDroidstubsDependency(t *testing.T) {
@@ -2485,6 +2547,9 @@
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo"),
+ android.FixtureModifyConfig(func(config android.Config) {
+ config.SetApiLibraries([]string{"foo"})
+ }),
android.FixtureMergeMockFs(
map[string][]byte{
"A.java": nil,
@@ -2533,6 +2598,7 @@
PrepareForTestWithJacocoInstrumentation,
FixtureWithLastReleaseApis("foo"),
android.FixtureModifyConfig(func(config android.Config) {
+ config.SetApiLibraries([]string{"foo"})
config.SetBuildFromTextStub(true)
}),
android.FixtureModifyEnv(func(env map[string]string) {