Merge "Propagate stub_only_libs to the invocation generating stub sources"

This commit is contained in:
Nikita Ioffe 2022-11-21 22:55:46 +00:00 committed by Gerrit Code Review
commit 663e060c64
2 changed files with 27 additions and 0 deletions

View file

@ -1648,6 +1648,7 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC
// shared libs and static libs. So we need to add both of these libs to Libs property.
props.Libs = module.properties.Libs
props.Libs = append(props.Libs, module.properties.Static_libs...)
props.Libs = append(props.Libs, module.sdkLibraryProperties.Stub_only_libs...)
props.Aidl.Include_dirs = module.deviceProperties.Aidl.Include_dirs
props.Aidl.Local_include_dirs = module.deviceProperties.Aidl.Local_include_dirs
props.Java_version = module.properties.Java_version

View file

@ -1385,3 +1385,29 @@ func TestSdkLibrary_CheckMinSdkVersion(t *testing.T) {
}
`)
}
func TestJavaSdkLibrary_StubOnlyLibs_PassedToDroidstubs(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo"),
).RunTestWithBp(t, `
java_sdk_library {
name: "foo",
srcs: ["a.java"],
public: {
enabled: true,
},
stub_only_libs: ["bar-lib"],
}
java_library {
name: "bar-lib",
srcs: ["b.java"],
}
`)
// The foo.stubs.source should depend on bar-lib
fooStubsSources := result.ModuleForTests("foo.stubs.source", "android_common").Module().(*Droidstubs)
android.AssertStringListContains(t, "foo stubs should depend on bar-lib", fooStubsSources.Javadoc.properties.Libs, "bar-lib")
}