Build a core-current-stubs-for-system-modules jar

The classes used to generate core-current-stubs-system-modules
need to be distributed in the SDK so that other build systems
can link their own system modules.

Bug: 143209928
Test: m TARGET_PRODUCT=sdk_phone_x86 TARGET_BUILD_VARIANT=userdebug sdk sdk_repo dist
Change-Id: Id6ebfbfcd26c379b6721ef04fb5d0c437bbe37cf
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index f334613..0371887 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -386,6 +386,7 @@
     srcs: [
         ":openjdk_lambda_stub_files",
     ],
+    include_srcs: true,
 }
 
 // Creates a jar that exists to satisfy javac when compiling source code that
@@ -912,11 +913,12 @@
     },
 }
 
-// Used when compiling higher-level code against core.current.stubs.
-java_system_modules {
-    name: "core-current-stubs-system-modules",
-    visibility: ["//visibility:public"],
-    libs: [
+// Distributed with the SDK for turning into system modules to compile apps
+// against.
+java_library {
+    name: "core-current-stubs-for-system-modules",
+    visibility: ["//development/sdk"],
+    static_libs: [
         "core.current.stubs",
         // This one is not on device but it's needed when javac compiles code
         // containing lambdas.
@@ -927,6 +929,24 @@
         // See http://b/123891440.
         "core-generated-annotation-stubs",
     ],
+    sdk_version: "none",
+    system_modules: "none",
+    dist: {
+        dest: "core-for-system-modules.jar",
+        targets: [
+            "sdk",
+            "win_sdk",
+        ],
+    },
+}
+
+// Used when compiling higher-level code against core.current.stubs.
+java_system_modules {
+    name: "core-current-stubs-system-modules",
+    visibility: ["//visibility:public"],
+    libs: [
+        "core-current-stubs-for-system-modules",
+    ],
 }
 
 // Target for validating nullability annotations for correctness and