don't export systemserverclasspath_fragment if contents are empty

If a systemserverclasspath_fragment only contains libraries that have a
higher min_sdk_version than the target build release version, then we
should not export the systemserverclasspath_fragment. Before this
change, the fragment was exported with an empty `contents` property
which caused errors after being dropped as a prebuilt.

Bug: 289183551
Test: go test ./sdk
Change-Id: Ifefc6880228e4dd37f5e42b2bda31a83df785375
This commit is contained in:
Sam Delmerico
2023-06-30 14:40:10 -04:00
parent a56663f695
commit 35881365b4
4 changed files with 136 additions and 10 deletions

View File

@@ -1194,3 +1194,58 @@ java_sdk_library_import {
expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "")
})
}
func TestSnapshotWithEmptyBootClasspathFragment(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("mysdklibrary", "mynewsdklibrary"),
java.FixtureConfigureApexBootJars("myapex:mysdklibrary", "myapex:mynewsdklibrary"),
prepareForSdkTestWithApex,
// Add a platform_bootclasspath that depends on the fragment.
fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
android.FixtureMergeEnv(map[string]string{
"SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": "S",
}),
android.FixtureWithRootAndroidBp(`
sdk {
name: "mysdk",
apexes: ["myapex"],
}
apex {
name: "myapex",
key: "myapex.key",
min_sdk_version: "S",
bootclasspath_fragments: ["mybootclasspathfragment"],
}
bootclasspath_fragment {
name: "mybootclasspathfragment",
apex_available: ["myapex"],
contents: ["mysdklibrary", "mynewsdklibrary"],
hidden_api: {
split_packages: [],
},
}
java_sdk_library {
name: "mysdklibrary",
apex_available: ["myapex"],
srcs: ["Test.java"],
shared_library: false,
public: {enabled: true},
min_sdk_version: "Tiramisu",
}
java_sdk_library {
name: "mynewsdklibrary",
apex_available: ["myapex"],
srcs: ["Test.java"],
compile_dex: true,
public: {enabled: true},
min_sdk_version: "Tiramisu",
permitted_packages: ["mynewsdklibrary"],
}
`),
).RunTest(t)
CheckSnapshot(t, result, "mysdk", "", checkAndroidBpContents(`// This is auto-generated. DO NOT EDIT.`))
}