Refactor merged annotations creation

It's clearer to define the module in Android.bp, and keep
our custom Go code to the minimal. The only thing the go
code really needs to do is create a "all module annotations"
module. This matches the pattern of the other modules here (the
pattern was invented after sdk-annotations.zip was first
migrated).

Bug: 235140934
Test: m sdk-annotations.zip before/after (no diffs)
Change-Id: Iae246081bcf4e5177d1da98c2e01c702fb349a22
diff --git a/api/Android.bp b/api/Android.bp
index 69d602a..9a14ee6 100644
--- a/api/Android.bp
+++ b/api/Android.bp
@@ -188,6 +188,23 @@
         "$(location :frameworks-base-api-module-lib-current.txt)",
 }
 
+// This produces the same annotations.zip as framework-doc-stubs, but by using
+// outputs from individual modules instead of all the source code.
+genrule {
+    name: "sdk-annotations.zip",
+    srcs: [
+        ":android-non-updatable-doc-stubs{.annotations.zip}",
+        ":all-modules-public-annotations",
+    ],
+    out: ["annotations.zip"],
+    tools: [
+        "merge_annotation_zips",
+        "soong_zip",
+    ],
+    cmd: "$(location merge_annotation_zips) $(genDir)/out $(in) && " +
+        "$(location soong_zip) -o $(out) -C $(genDir)/out -D $(genDir)/out",
+}
+
 genrule {
     name: "combined-removed-dex",
     visibility: [