Enable `rules_java` CI for Bazel 6

PiperOrigin-RevId: 691295884
Change-Id: Icf93e679c3a919983553ce47cd502e72d3216b15
diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml
index 3e2417f..f89bc94 100644
--- a/.bazelci/presubmit.yml
+++ b/.bazelci/presubmit.yml
@@ -9,14 +9,10 @@
   - "-//java/docs/..."
   - "-//test:docs_up_to_date_test"
 
-build_targets_bzlmod: &build_targets_bzlmod
-  - "//..."
+build_targets_bazel6: &build_targets_bazel6
+  - "//:all"
   - "@remote_java_tools//java_tools/..."
-  - "-//toolchains/..."
-  # TODO(pcloudy): pkg_tar doesn't work with Bzlmod due to https://github.com/bazelbuild/bazel/issues/14259
-  # Enable once the issue is fixed.
-  - "-//distro/..."
-  - "-//test/repo/..."
+  - "//examples/..."
 
 test_targets: &test_targets
   - "//test/..."
@@ -81,20 +77,30 @@
     bazel: last_green
     platform: windows
     build_targets: *build_targets
+
 # Bazel 6.x
-# TODO: re-enable if possible to redirect to native rule impl
-#  ubuntu2004_bazel630:
-#    name: "Bazel 6.3.0"
-#    bazel: 6.3.0
-#    platform: ubuntu2004
-#    build_targets: *build_targets
-#  macos_bazel630:
-#    name: "Bazel 6.3.0"
-#    bazel: 6.3.0
-#    platform: macos
-#    build_targets: *build_targets
-#  windows_bazel630:
-#    name: "Bazel 6.3.0"
-#    bazel: 6.3.0
-#    platform: windows
-#    build_targets: *build_targets
+  ubuntu2004_bazel6:
+    name: "Bazel 6.x"
+    bazel: 6.5.0
+    platform: ubuntu2004
+    build_targets: *build_targets_bazel6
+  ubuntu2004_integration_bazel6:
+    name: "Bazel 6.x Integration"
+    bazel: "6.5.0"
+    platform: ubuntu2004
+    working_directory: "test/repo"
+    shell_commands:
+    - sh setup.sh
+    build_targets:
+    - "//..."
+    - "//:bin_deploy.jar"
+  macos_bazel6:
+    name: "Bazel 6.x"
+    bazel: 6.5.0
+    platform: macos
+    build_targets: *build_targets_bazel6
+  windows_bazel6:
+    name: "Bazel 6.x"
+    bazel: 6.5.0
+    platform: windows
+    build_targets: *build_targets_bazel6
diff --git a/WORKSPACE b/WORKSPACE
index 6e4b3c0..669f974 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -27,3 +27,22 @@
 load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
 
 rules_pkg_dependencies()
+
+http_archive(
+    name = "stardoc",
+    sha256 = "62bd2e60216b7a6fec3ac79341aa201e0956477e7c8f6ccc286f279ad1d96432",
+    urls = [
+        "https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.6.2/stardoc-0.6.2.tar.gz",
+        "https://github.com/bazelbuild/stardoc/releases/download/0.6.2/stardoc-0.6.2.tar.gz",
+    ],
+)
+
+load("@stardoc//:setup.bzl", "stardoc_repositories")
+
+stardoc_repositories()
+
+load("//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
+
+rules_java_dependencies()
+
+rules_java_toolchains()
diff --git a/java/repositories.bzl b/java/repositories.bzl
index 712560f..84892d2 100644
--- a/java/repositories.bzl
+++ b/java/repositories.bzl
@@ -360,6 +360,35 @@
     """Imports OpenJDK 21 repositories."""
     _remote_jdk_repos_for_version("21")
 
+def protobuf_repo():
+    maybe(
+        http_archive,
+        name = "protobuf",
+        sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
+        strip_prefix = "protobuf-27.0",
+        url = "https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
+    )
+
+def rules_cc_repo():
+    maybe(
+        http_archive,
+        name = "rules_cc",
+        sha256 = "d9bdd3ec66b6871456ec9c965809f43a0901e692d754885e89293807762d3d80",
+        strip_prefix = "rules_cc-0.0.13",
+        urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.13/rules_cc-0.0.13.tar.gz"],
+    )
+
+def bazel_skylib_repo():
+    maybe(
+        http_archive,
+        name = "bazel_skylib",
+        sha256 = "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728",
+        urls = [
+            "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz",
+            "https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz",
+        ],
+    )
+
 def rules_java_dependencies():
     """An utility method to load all dependencies of rules_java.
 
@@ -372,6 +401,10 @@
     remote_jdk17_repos()
     remote_jdk21_repos()
     java_tools_repos()
+    compatibility_proxy_repo()
+    protobuf_repo()
+    rules_cc_repo()
+    bazel_skylib_repo()
 
 def rules_java_toolchains(name = "toolchains"):
     """An utility method to load all Java toolchains.
diff --git a/test/repo/WORKSPACE b/test/repo/WORKSPACE
new file mode 100644
index 0000000..c961444
--- /dev/null
+++ b/test/repo/WORKSPACE
@@ -0,0 +1,10 @@
+local_repository(
+    name = "rules_java",
+    path = "../../",
+)
+
+load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
+
+rules_java_dependencies()
+
+rules_java_toolchains()