Add annotations.zip support to java_sdk_library

The annotations zip file is produced by the "main" sdk build and is
primarily consumed by android studio.

In order to support building the main SDK without requiring the sources
of all modules, we are adding module SDK artifacts that allows
reconstructing these outputs. The annotations zip contains XML files
which should be fairly easy to merge from all the individual parts.

Bug: 187397779
Test: unit tests in this CL
Test: m sdkextensions-sdk and inspect output
Merged-In: I955cae720e6f1382936836ee1d8fb11003f51b7d
Change-Id: I955cae720e6f1382936836ee1d8fb11003f51b7d
This commit is contained in:
Anton Hansson
2021-09-21 15:25:12 +01:00
parent d446d282ed
commit 3adf3c52eb
5 changed files with 112 additions and 5 deletions

View File

@@ -247,12 +247,37 @@ func TestJavaSdkLibrary_DoNotAccessImplWhenItIsNotBuilt(t *testing.T) {
}
}
func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) {
func TestJavaSdkLibrary_AccessOutputFiles(t *testing.T) {
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo"),
).RunTestWithBp(t, `
java_sdk_library {
name: "foo",
srcs: ["a.java"],
api_packages: ["foo"],
annotations_enabled: true,
public: {
enabled: true,
},
}
java_library {
name: "bar",
srcs: ["b.java", ":foo{.public.stubs.source}"],
java_resources: [":foo{.public.annotations.zip}"],
}
`)
}
func TestJavaSdkLibrary_AccessOutputFiles_NoAnnotations(t *testing.T) {
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("foo"),
).
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "bar" variant "android_common": path dependency ":foo{.public.annotations.zip}": annotations.zip not available for api scope public`)).
RunTestWithBp(t, `
java_sdk_library {
name: "foo",
srcs: ["a.java"],
@@ -265,6 +290,7 @@ func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) {
java_library {
name: "bar",
srcs: ["b.java", ":foo{.public.stubs.source}"],
java_resources: [":foo{.public.annotations.zip}"],
}
`)
}
@@ -328,6 +354,7 @@ func TestJavaSdkLibraryImport_AccessOutputFiles(t *testing.T) {
stub_srcs: ["a.java"],
current_api: "api/current.txt",
removed_api: "api/removed.txt",
annotations: "x/annotations.zip",
},
}
@@ -337,6 +364,7 @@ func TestJavaSdkLibraryImport_AccessOutputFiles(t *testing.T) {
java_resources: [
":foo{.public.api.txt}",
":foo{.public.removed-api.txt}",
":foo{.public.annotations.zip}",
],
}
`)