Embed art/libcore NOTICE files into its stubs

This simplifies the "global" stubs build rules and makes it easier to
recreate without finalizing more artifacts.

Bug: 184839599
Bug: 173186484
Test: m android_stubs_current ; unzip -l <path> | grep NOTICE
Change-Id: I3ac48cc30e66563e38768d5aef64e5253712f3cd
diff --git a/Android.bp b/Android.bp
index 0ce778c..b599141 100644
--- a/Android.bp
+++ b/Android.bp
@@ -62,27 +62,16 @@
     "NativeCode.bp",
 ]
 
-genrule {
-    name: "notices-for-framework-stubs-gen",
+java_genrule {
+    name: "notices-for-stubs-jar",
+    tools: ["soong_zip"],
     tool_files: [
         "NOTICE",
         "ojluni/NOTICE",
     ],
-    cmd: "cp -f $(location NOTICE) $(genDir)/NOTICES/libcore-NOTICE && cp -f $(location ojluni/NOTICE) $(genDir)/NOTICES/ojluni-NOTICE",
-    out: [
-        "NOTICES/libcore-NOTICE",
-        "NOTICES/ojluni-NOTICE",
-    ],
-}
-
-java_library {
-    name: "art-notices-for-framework-stubs-jar",
-    visibility: [
-        "//art/build/sdk",
-        "//frameworks/base",
-    ],
-    java_resources: [
-        ":notices-for-framework-stubs-gen",
-    ],
-    sdk_version: "core_current",
+    cmd: "mkdir $(genDir)/NOTICES && " +
+        "cp -f $(location NOTICE) $(genDir)/NOTICES/libcore-NOTICE && " +
+        "cp -f $(location ojluni/NOTICE) $(genDir)/NOTICES/ojluni-NOTICE && " +
+        "$(location soong_zip) -o $(out) -C $(genDir) -D $(genDir)/NOTICES",
+    out: ["notices-for-stubs.jar"],
 }
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index 9a2124a..4837be7 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -886,6 +886,7 @@
         // android.icu.text.CollationElementIterator.NULLORDER.
         "i18n.module.intra.core.api.stubs",
     ],
+    stub_only_static_libs: ["notices-for-stubs-jar"],
     java_version: "1.9",
 
     // Make dex jars for the stubs available for use by hiddenapi processing.