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
Change-Id: I955cae720e6f1382936836ee1d8fb11003f51b7d
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index d6c0946..be23536 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -248,7 +248,7 @@
}
}
-func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) {
+func TestJavaSdkLibrary_AccessOutputFiles(t *testing.T) {
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -258,6 +258,31 @@
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"],
+ api_packages: ["foo"],
public: {
enabled: true,
},
@@ -266,6 +291,7 @@
java_library {
name: "bar",
srcs: ["b.java", ":foo{.public.stubs.source}"],
+ java_resources: [":foo{.public.annotations.zip}"],
}
`)
}
@@ -329,6 +355,7 @@
stub_srcs: ["a.java"],
current_api: "api/current.txt",
removed_api: "api/removed.txt",
+ annotations: "x/annotations.zip",
},
}
@@ -338,6 +365,7 @@
java_resources: [
":foo{.public.api.txt}",
":foo{.public.removed-api.txt}",
+ ":foo{.public.annotations.zip}",
],
}
`)