Generate private-stub-annotations jar

Use genrule to hanle this oneoff Metalava invocation case, and then
compile jar as how we do for stub-annotations jar.

Test: m -j private-stub-annotations-jar
Bug: b/78245848
Change-Id: Idc5d33e796763696f1536b549c8d17ffcb45f661
diff --git a/Android.bp b/Android.bp
index a606a75..edbfb08 100644
--- a/Android.bp
+++ b/Android.bp
@@ -35,3 +35,28 @@
     ],
     no_framework_libs: true,
 }
+
+genrule {
+    name: "private-stub-annotations",
+    tools: [
+        "soong_zip",
+        "metalava",
+    ],
+    srcs: [
+        "stub-annotations/src/main/java/**/*.java",
+    ],
+    cmd: "($(location metalava) --no-banner --copy-annotations tools/metalava/stub-annotations " +
+         "$(genDir)/private-stub-annotations) && ($(location soong_zip) -o $(out) -C $(genDir) -D $(genDir))",
+    out: [
+        "private-stub-annotations.srcjar",
+    ],
+}
+
+java_library {
+    name: "private-stub-annotations-jar",
+    host_supported: true,
+    srcs: [
+        ":private-stub-annotations",
+    ],
+    no_framework_libs: true,
+}