SdkTestCore for non-updatable modules
Provides SdkTestCore/test_core_current sdk_version for non-updatable
modules that have their test scope dependent on test apis from
framework-minus-apex.
Ignore-AOSP-First: Change in topic with internal-first projects
Bug: 289776578
Test: m checkapi | go test ./java
Merged-In: Iba3213e8c34ea75ac9dd8532a95ef62fb5455e6c
Change-Id: Iba3213e8c34ea75ac9dd8532a95ef62fb5455e6c
diff --git a/java/sdk.go b/java/sdk.go
index 7c702c4..ddd99bb 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -76,7 +76,8 @@
// Core is by definition what is included in the system module for the public API so should
// just use its system modules.
systemModuleKind = android.SdkPublic
- } else if systemModuleKind == android.SdkSystem || systemModuleKind == android.SdkTest {
+ } else if systemModuleKind == android.SdkSystem || systemModuleKind == android.SdkTest ||
+ systemModuleKind == android.SdkTestFrameworksCore {
// The core system and test APIs are currently the same as the public API so they should use
// its system modules.
systemModuleKind = android.SdkPublic
@@ -192,7 +193,7 @@
bootclasspath: corePlatformBootclasspathLibraries(ctx),
noFrameworksLibs: true,
}
- case android.SdkPublic, android.SdkSystem, android.SdkTest:
+ case android.SdkPublic, android.SdkSystem, android.SdkTest, android.SdkTestFrameworksCore:
return toModule(sdkVersion.Kind.DefaultJavaLibraryName(), sdkFrameworkAidlPath(ctx))
case android.SdkCore:
return sdkDep{
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 041aeb7..4ad3907 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -470,6 +470,9 @@
// or the API file. They both have to use the same sdk_version as is used for
// compiling the implementation library.
Sdk_version *string
+
+ // Extra libs used when compiling stubs for this scope.
+ Libs []string
}
type sdkLibraryProperties struct {
@@ -1653,6 +1656,7 @@
props.Patch_module = module.properties.Patch_module
props.Installable = proptools.BoolPtr(false)
props.Libs = module.sdkLibraryProperties.Stub_only_libs
+ props.Libs = append(props.Libs, module.scopeToProperties[apiScope].Libs...)
props.Static_libs = module.sdkLibraryProperties.Stub_only_static_libs
// The stub-annotations library contains special versions of the annotations
// with CLASS retention policy, so that they're kept.
@@ -1725,6 +1729,7 @@
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.Libs = append(props.Libs, module.scopeToProperties[apiScope].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
@@ -1864,6 +1869,7 @@
props.Api_contributions = apiContributions
props.Libs = module.properties.Libs
props.Libs = append(props.Libs, module.sdkLibraryProperties.Stub_only_libs...)
+ props.Libs = append(props.Libs, module.scopeToProperties[apiScope].Libs...)
props.Libs = append(props.Libs, "stub-annotations")
props.Static_libs = module.sdkLibraryProperties.Stub_only_static_libs
props.Full_api_surface_stub = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName())
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 0b46919..21f0bab 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -1421,6 +1421,32 @@
android.AssertStringListContains(t, "foo stubs should depend on bar-lib", fooStubsSources.Javadoc.properties.Libs, "bar-lib")
}
+func TestJavaSdkLibrary_Scope_Libs_PassedToDroidstubs(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ PrepareForTestWithJavaSdkLibraryFiles,
+ FixtureWithLastReleaseApis("foo"),
+ ).RunTestWithBp(t, `
+ java_sdk_library {
+ name: "foo",
+ srcs: ["a.java"],
+ public: {
+ enabled: true,
+ 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")
+}
+
func TestJavaSdkLibrary_ApiLibrary(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForJavaTest,