Improve the JDK and JRE filegroups to include all the necessary parts. Then fix the Skylark rules and tests that so far failed to declare dependencies on the JVM.

--
MOS_MIGRATED_REVID=101215495
diff --git a/tools/build_rules/genproto.bzl b/tools/build_rules/genproto.bzl
index a2e2d73..d6e6a80 100644
--- a/tools/build_rules/genproto.bzl
+++ b/tools/build_rules/genproto.bzl
@@ -32,7 +32,7 @@
 
   ctx.action(
     command=" && ".join(sub_commands),
-    inputs=[ctx.file.src, proto_compiler, ctx.file._jar],
+    inputs=[ctx.file.src, proto_compiler, ctx.file._jar] + ctx.files._jdk,
     outputs=[out],
     mnemonic="GenProtoSrcJar",
     use_default_shell_env = True)
@@ -40,17 +40,20 @@
 gensrcjar = rule(
   gensrcjar_impl,
   attrs={
-        "src": attr.label(allow_files=proto_filetype, single_file=True),
-        # TODO(bazel-team): this should be a hidden attribute with a default
-        # value, but Skylark needs to support select first.
-        "_proto_compiler": attr.label(
-            default=Label("//third_party:protoc"),
-            allow_files=True,
-            single_file=True),
-        "_jar": attr.label(
-            default=Label("//external:jar"),
-            allow_files=True,
-            single_file=True),
+      "src": attr.label(allow_files=proto_filetype, single_file=True),
+      # TODO(bazel-team): this should be a hidden attribute with a default
+      # value, but Skylark needs to support select first.
+      "_proto_compiler": attr.label(
+          default=Label("//third_party:protoc"),
+          allow_files=True,
+          single_file=True),
+      "_jar": attr.label(
+          default=Label("//tools/jdk:jar"),
+          allow_files=True,
+          single_file=True),
+      "_jdk": attr.label(
+          default=Label("//tools/jdk:jdk"),
+          allow_files=True),
   },
   outputs={"srcjar": "lib%{name}.srcjar"},
 )
diff --git a/tools/build_rules/java_rules_skylark.bzl b/tools/build_rules/java_rules_skylark.bzl
index 8a59f87..21b344d 100644
--- a/tools/build_rules/java_rules_skylark.bzl
+++ b/tools/build_rules/java_rules_skylark.bzl
@@ -81,7 +81,7 @@
          "touch " + build_output + "\n")
   ctx.action(
     inputs = (sources + compile_time_jars_list + [sources_param_file] +
-              ctx.files.resources + ctx.files.srcjars),
+              [ctx.file._jar] + ctx.files._jdk + ctx.files.resources + ctx.files.srcjars),
     outputs = [class_jar],
     mnemonic='Javac',
     command=cmd,
@@ -116,7 +116,7 @@
          "touch " + build_output + "\n")
 
   ctx.action(
-    inputs=list(library_result.runtime_jars) + [manifest],
+    inputs=list(library_result.runtime_jars) + [manifest] + ctx.files._jdk,
     outputs=[deploy_jar],
     mnemonic='Deployjar',
     command=cmd,
@@ -167,8 +167,7 @@
         ]),
     executable = True)
 
-  runfiles = ctx.runfiles(files = [
-      deploy_jar, executable] + ctx.files.jvm, collect_data = True)
+  runfiles = ctx.runfiles(files = [deploy_jar, executable] + ctx.files._jdk, collect_data = True)
   files_to_build = set([deploy_jar, manifest, executable])
   files_to_build += library_result.files
 
@@ -191,6 +190,7 @@
     "_java": attr.label(default=Label("//tools/jdk:java"), single_file=True),
     "_javac": attr.label(default=Label("//tools/jdk:javac"), single_file=True),
     "_jar": attr.label(default=Label("//tools/jdk:jar"), single_file=True),
+    "_jdk": attr.label(default=Label("//tools/jdk:jdk"), allow_files=True),
     "data": attr.label_list(allow_files=True, cfg=DATA_CFG),
     "resources": attr.label_list(allow_files=True),
     "srcs": attr.label_list(allow_files=java_filetype),
diff --git a/tools/jdk/BUILD b/tools/jdk/BUILD
index 87b3a0b..58db282 100644
--- a/tools/jdk/BUILD
+++ b/tools/jdk/BUILD
@@ -60,6 +60,17 @@
 )
 
 # This one is just needed because of how filegroup redirection works.
+filegroup(name = "jre-null")
+
+filegroup(
+    name = "jre",
+    srcs = [
+        ":jre-null",
+        "//external:jre-default",
+    ],
+)
+
+# This one is just needed because of how filegroup redirection works.
 filegroup(name = "jdk-null")
 
 filegroup(