Automated rollback of commit 22893a02ae09e44e3288ec3552d7bd128ae02dc0.

*** Reason for rollback ***

target '//third_party/bazel_rules/rules_java/java/constraints:srcs' is not visible from target '//buildenv/platforms/java:test_deps'

*** Original change description ***

Copybara Merge: https://github.com/bazelbuild/rules_java/pull/38

BEGIN_PUBLIC
Copybara import of the project:

--
b861a66582035afc59be80cc8026d7ed84b0d6d2 by Ivo List <ilist@google.com>:

Bump version to 4.1.0

--
dc3a245553d139dbd28cf6f2839d159d3bb06f6e by Ivo List <ilist@google.com>:

Add remote_java_repository macro.

--
d9537430ece3f7988ef7430e7507d5190aac3899 by Ivo List <ilist@google.com>:

Import JDKs using remote_java_repository macro.

--
712ae16a5b363a017da0aa6a7c07ce91acc89953 by Ivo...

***

PiperOrigin-RevId: 353240866
Change-Id: I724c85a3fef5f4ed43902a1f72a9da3e9f703f69
diff --git a/BUILD b/BUILD
index b87a792..f59256b 100644
--- a/BUILD
+++ b/BUILD
@@ -7,8 +7,8 @@
     srcs = [
         "BUILD",
         "LICENSE",
-        "//java:srcs",
-        "//toolchains:srcs",
-    ],
+    ] + glob([
+        "*.bzl",
+    ]),
     visibility = ["@//distro:__pkg__"],
 )
diff --git a/distro/BUILD b/distro/BUILD
index 71352e8..475697a 100644
--- a/distro/BUILD
+++ b/distro/BUILD
@@ -9,7 +9,10 @@
 # Build the artifact to put on the github release page.
 pkg_tar(
     name = "rules_java-%s" % version,
-    srcs = ["//:distribution"],
+    srcs = [
+        "//:distribution",
+        "//java:distribution",
+    ],
     extension = "tar.gz",
     # It is all source code, so make it read-only.
     mode = "0444",
diff --git a/java/BUILD b/java/BUILD
index 103b99a..abf9526 100644
--- a/java/BUILD
+++ b/java/BUILD
@@ -2,12 +2,15 @@
 
 licenses(["notice"])
 
+# TODO(aiuto): Find a way to strip this rule from the distribution tarball.
 filegroup(
-    name = "srcs",
+    name = "distribution",
     srcs = glob([
         "**",
     ]) + [
         "//java/constraints:srcs",
     ],
-    visibility = ["@//:__pkg__"],
+    visibility = [
+        "@//distro:__pkg__",
+    ],
 )
diff --git a/java/constraints/BUILD b/java/constraints/BUILD
index 857ec47..fbc5407 100644
--- a/java/constraints/BUILD
+++ b/java/constraints/BUILD
@@ -7,7 +7,6 @@
 filegroup(
     name = "srcs",
     srcs = ["BUILD"],
-    visibility = ["@//java:__pkg__"],
 )
 
 constraint_setting(name = "runtime")
diff --git a/java/defs.bzl b/java/defs.bzl
index 4c179a5..5ea8c19 100644
--- a/java/defs.bzl
+++ b/java/defs.bzl
@@ -15,7 +15,7 @@
 
 _MIGRATION_TAG = "__JAVA_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__"
 
-version = "4.1.0"
+version = "4.0.0"
 
 def _add_tags(attrs):
     if "tags" in attrs and attrs["tags"] != None:
diff --git a/java/repositories.bzl b/java/repositories.bzl
index 492186c..9beaf20 100644
--- a/java/repositories.bzl
+++ b/java/repositories.bzl
@@ -25,7 +25,6 @@
 
 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
 load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
-load("//toolchains:remote_java_repository.bzl", "remote_java_repository")
 
 def java_tools_javac11_repos():
     maybe(
@@ -65,64 +64,48 @@
     https://mirror.bazel.build/openjdk/azul-zulu-8.50.0.51-ca-jdk8.0.275/zsrc8.50.0.53-ca-fx-jdk8.0.275.zip
     """
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk8_linux_aarch64",
-        exec_compatible_with = [
-            "@platforms//os:linux",
-            "@platforms//cpu:aarch64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "f4072e82faa5a09fab2accf2892d4684324fc999d614583c3ff785e87c03963f",
         strip_prefix = "zulu8.50.51.263-ca-jdk8.0.275-linux_aarch64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu-8.50.0.51-ca-jdk8.0.275/zulu8.50.51.263-ca-jdk8.0.275-linux_aarch64.tar.gz",
             "https://cdn.azul.com/zulu-embedded/bin/zulu8.50.51.263-ca-jdk8.0.275-linux_aarch64.tar.gz",
         ],
-        version = "8",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk8_linux",
-        exec_compatible_with = [
-            "@platforms//os:linux",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "1db6b2fa642950ee1b4b1ec2b6bc8a9113d7a4cd723f79398e1ada7dab1c981c",
         strip_prefix = "zulu8.50.0.51-ca-jdk8.0.275-linux_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu-8.50.0.51-ca-jdk8.0.275/zulu8.50.0.51-ca-jdk8.0.275-linux_x64.tar.gz",
             "https://cdn.azul.com/zulu/bin/zulu8.50.0.51-ca-jdk8.0.275-linux_x64.tar.gz",
         ],
-        version = "8",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk8_macos",
-        exec_compatible_with = [
-            "@platforms//os:macos",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "b03176597734299c9a15b7c2cc770783cf14d121196196c1248e80c026b59c17",
         strip_prefix = "zulu8.50.0.51-ca-jdk8.0.275-macosx_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu-8.50.0.51-ca-jdk8.0.275/zulu8.50.0.51-ca-jdk8.0.275-macosx_x64.tar.gz",
             "https://cdn.azul.com/zulu/bin/zulu8.50.0.51-ca-jdk8.0.275-macosx_x64.tar.gz",
         ],
-        version = "8",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk8_windows",
-        exec_compatible_with = [
-            "@platforms//os:windows",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "49759b2bd2ab28231a21ff3a3bb45824ddef55d89b5b1a05a62e26a365da0774",
         strip_prefix = "zulu8.50.0.51-ca-jdk8.0.275-win_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu-8.50.0.51-ca-jdk8.0.275/zulu8.50.0.51-ca-jdk8.0.275-win_x64.zip",
             "https://cdn.azul.com/zulu/bin/zulu8.50.0.51-ca-jdk8.0.275-win_x64.zip",
         ],
-        version = "8",
     )
 
 def remote_jdk9_repos():
@@ -134,12 +117,9 @@
     https://mirror.bazel.build/openjdk/azul-zulu-9.0.7.1-jdk9.0.7/zsrc9.0.7.1-jdk9.0.7.zip
     """
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk9_linux_aarch64",
-        exec_compatible_with = [
-            "@platforms//os:linux",
-            "@platforms//cpu:aarch64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "72e7843902b0395e2d30e1e9ad2a5f05f36a4bc62529828bcbc698d54aec6022",
         strip_prefix = "jdk9-server-release-1708",
         urls = [
@@ -147,48 +127,35 @@
             "https://mirror.bazel.build/openjdk.linaro.org/releases/jdk9-server-release-170bazel_skylib8.tar.xz",
             "http://openjdk.linaro.org/releases/jdk9-server-release-1708.tar.xz",
         ],
-        version = "9",
     )
 
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk9_linux",
-        exec_compatible_with = [
-            "@platforms//os:linux",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "45f2dfbee93b91b1468cf81d843fc6d9a47fef1f831c0b7ceff4f1eb6e6851c8",
         strip_prefix = "zulu9.0.7.1-jdk9.0.7-linux_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu-9.0.7.1-jdk9.0.7/zulu9.0.7.1-jdk9.0.7-linux_x64.tar.gz",
         ],
-        version = "9",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk9_macos",
-        exec_compatible_with = [
-            "@platforms//os:macos",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         strip_prefix = "zulu9.0.7.1-jdk9.0.7-macosx_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu-9.0.7.1-jdk9.0.7/zulu9.0.7.1-jdk9.0.7-macosx_x64.tar.gz",
         ],
-        version = "9",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk9_windows",
-        exec_compatible_with = [
-            "@platforms//os:windows",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         strip_prefix = "zulu9.0.7.1-jdk9.0.7-win_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu-9.0.7.1-jdk9.0.7/zulu9.0.7.1-jdk9.0.7-win_x64.zip",
         ],
-        version = "9",
     )
 
 def remote_jdk10_repos():
@@ -201,12 +168,9 @@
     """
 
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk10_linux_aarch64",
-        exec_compatible_with = [
-            "@platforms//os:linux",
-            "@platforms//cpu:aarch64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "b7098b7aaf6ee1ffd4a2d0371a0be26c5a5c87f6aebbe46fe9a92c90583a84be",
         strip_prefix = "jdk10-server-release-1804",
         urls = [
@@ -214,49 +178,36 @@
             "https://mirror.bazel.build/openjdk.linaro.org/releases/jdk10-server-release-1804.tar.xz",
             "http://openjdk.linaro.org/releases/jdk10-server-release-1804.tar.xz",
         ],
-        version = "10",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk10_linux",
-        exec_compatible_with = [
-            "@platforms//os:linux",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "b3c2d762091a615b0c1424ebbd05d75cc114da3bf4f25a0dec5c51ea7e84146f",
         strip_prefix = "zulu10.2+3-jdk10.0.1-linux_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu10.2+3-jdk10.0.1/zulu10.2+3-jdk10.0.1-linux_x64.tar.gz",
         ],
-        version = "10",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk10_macos",
-        exec_compatible_with = [
-            "@platforms//os:macos",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "7394d5f41804cfbdb47c609879c4e738bf53358484ea0995076190915b94c702",
         strip_prefix = "zulu10.2+3-jdk10.0.1-macosx_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu10.2+3-jdk10.0.1/zulu10.2+3-jdk10.0.1-macosx_x64.tar.gz",
         ],
-        version = "10",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk10_windows",
-        exec_compatible_with = [
-            "@platforms//os:windows",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "fd9456b53dab8b9f504ed0f0e2f6305bd0815978d0e02a41643d111290bf940c",
         strip_prefix = "zulu10.2+3-jdk10.0.1-win_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu10.2+3-jdk10.0.1/zulu10.2+3-jdk10.0.1-win_x64.zip",
         ],
-        version = "10",
     )
 
 def remote_jdk11_repos():
@@ -269,79 +220,67 @@
     """
 
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk11_linux_aarch64",
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "a452f1b9682d9f83c1c14e54d1446e1c51b5173a3a05dcb013d380f9508562e4",
         strip_prefix = "zulu11.37.48-ca-jdk11.0.6-linux_aarch64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu11.37.48-ca-jdk11.0.6/zulu11.37.48-ca-jdk11.0.6-linux_aarch64.tar.gz",
         ],
-        version = "11",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk11_linux",
         build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "360626cc19063bc411bfed2914301b908a8f77a7919aaea007a977fa8fb3cde1",
-        exec_compatible_with = [
-            "@platforms//os:linux",
-            "@platforms//cpu:x86_64",
-        ],
+        strip_prefix = "zulu11.37.17-ca-jdk11.0.6-linux_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu11.37.17-ca-jdk11.0.6/zulu11.37.17-ca-jdk11.0.6-linux_x64.tar.gz",
         ],
-        version = "11",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk11_macos",
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "e1fe56769f32e2aaac95e0a8f86b5a323da5af3a3b4bba73f3086391a6cc056f",
         strip_prefix = "zulu11.37.17-ca-jdk11.0.6-macosx_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu11.37.17-ca-jdk11.0.6/zulu11.37.17-ca-jdk11.0.6-macosx_x64.tar.gz",
         ],
-        version = "11",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk11_windows",
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "a9695617b8374bfa171f166951214965b1d1d08f43218db9a2a780b71c665c18",
         strip_prefix = "zulu11.37.17-ca-jdk11.0.6-win_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu11.37.17-ca-jdk11.0.6/zulu11.37.17-ca-jdk11.0.6-win_x64.zip",
         ],
-        version = "11",
     )
 
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk11_linux_ppc64le",
-        exec_compatible_with = [
-            "@platforms//os:linux",
-            "@platforms//cpu:ppc",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "a417db0295b1f4b538ecbaf7c774f3a177fab9657a665940170936c0eca4e71a",
         strip_prefix = "jdk-11.0.7+10",
         urls = [
             "https://mirror.bazel.build/openjdk/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7+10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.7_10.tar.gz",
             "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7+10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.7_10.tar.gz",
         ],
-        version = "11",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk11_linux_s390x",
-        exec_compatible_with = [
-            "@platforms//os:linux",
-            "@platforms//cpu:s390x",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "d9b72e87a1d3ebc0c9552f72ae5eb150fffc0298a7cb841f1ce7bfc70dcd1059",
         strip_prefix = "jdk-11.0.7+10",
         urls = [
             "https://mirror.bazel.build/github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7+10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.7_10.tar.gz",
             "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7+10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.7_10.tar.gz",
         ],
-        version = "11",
     )
 
 def remote_jdk12_repos():
@@ -351,135 +290,99 @@
     https://mirror.bazel.build/openjdk/azul-zulu12.2.3-ca-jdk12.0.1/zsrc12.2.3-jdk12.0.1.zip
     """
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk12_linux",
-        exec_compatible_with = [
-            "@platforms//os:linux",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "529c99841d69e11a85aea967ccfb9d0fd40b98c5b68dbe1d059002655e0a9c13",
         strip_prefix = "zulu12.2.3-ca-jdk12.0.1-linux_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu12.2.3-ca-jdk12.0.1/zulu12.2.3-ca-jdk12.0.1-linux_x64.tar.gz",
         ],
-        version = "12",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk12_macos",
-        exec_compatible_with = [
-            "@platforms//os:macos",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "67ca9d285056132ebb19fa237a14affda52132142e1171fe1c20e18974b3b8a5",
         strip_prefix = "zulu12.2.3-ca-jdk12.0.1-macosx_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu12.2.3-ca-jdk12.0.1/zulu12.2.3-ca-jdk12.0.1-macosx_x64.tar.gz",
         ],
-        version = "12",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk12_windows",
-        exec_compatible_with = [
-            "@platforms//os:windows",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "cf28404c23c3aa1115363ba6e796c30580a768e1d7d6681a7d053e516008e00d",
         strip_prefix = "zulu12.2.3-ca-jdk12.0.1-win_x64",
         urls = [
             "https://mirror.bazel.build/openjdk/azul-zulu12.2.3-ca-jdk12.0.1/zulu12.2.3-ca-jdk12.0.1-win_x64.zip",
         ],
-        version = "12",
     )
 
 def remote_jdk14_repos():
     """Imports OpenJDK 14 repositories."""
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk14_linux",
-        exec_compatible_with = [
-            "@platforms//os:linux",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "48bb8947034cd079ad1ef83335e7634db4b12a26743a0dc314b6b861480777aa",
         strip_prefix = "zulu14.28.21-ca-jdk14.0.1-linux_x64",
         urls = [
             "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu14.28.21-ca-jdk14.0.1-linux_x64.tar.gz",
         ],
-        version = "14",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk14_macos",
-        exec_compatible_with = [
-            "@platforms//os:macos",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "088bd4d0890acc9f032b738283bf0f26b2a55c50b02d1c8a12c451d8ddf080dd",
         strip_prefix = "zulu14.28.21-ca-jdk14.0.1-macosx_x64",
         urls = ["https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu14.28.21-ca-jdk14.0.1-macosx_x64.tar.gz"],
-        version = "14",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk14_windows",
-        exec_compatible_with = [
-            "@platforms//os:windows",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "9cb078b5026a900d61239c866161f0d9558ec759aa15c5b4c7e905370e868284",
         strip_prefix = "zulu14.28.21-ca-jdk14.0.1-win_x64",
         urls = ["https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu14.28.21-ca-jdk14.0.1-win_x64.zip"],
-        version = "14",
     )
 
 def remote_jdk15_repos():
     """Imports OpenJDK 15 repositories."""
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk15_linux",
-        exec_compatible_with = [
-            "@platforms//os:linux",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "0a38f1138c15a4f243b75eb82f8ef40855afcc402e3c2a6de97ce8235011b1ad",
         strip_prefix = "zulu15.27.17-ca-jdk15.0.0-linux_x64",
         urls = [
             "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu15.27.17-ca-jdk15.0.0-linux_x64.tar.gz",
             "https://cdn.azul.com/zulu/bin/zulu15.27.17-ca-jdk15.0.0-linux_x64.tar.gz",
         ],
-        version = "15",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk15_macos",
-        exec_compatible_with = [
-            "@platforms//os:macos",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "f80b2e0512d9d8a92be24497334c974bfecc8c898fc215ce0e76594f00437482",
         strip_prefix = "zulu15.27.17-ca-jdk15.0.0-macosx_x64",
         urls = [
             "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu15.27.17-ca-jdk15.0.0-macosx_x64.tar.gz",
             "https://cdn.azul.com/zulu/bin/zulu15.27.17-ca-jdk15.0.0-macosx_x64.tar.gz",
         ],
-        version = "15",
     )
     maybe(
-        remote_java_repository,
+        http_archive,
         name = "remote_jdk15_windows",
-        exec_compatible_with = [
-            "@platforms//os:windows",
-            "@platforms//cpu:x86_64",
-        ],
+        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
         sha256 = "f535a530151e6c20de8a3078057e332b08887cb3ba1a4735717357e72765cad6",
         strip_prefix = "zulu15.27.17-ca-jdk15.0.0-win_x64",
         urls = [
             "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu15.27.17-ca-jdk15.0.0-win_x64.zip",
             "https://cdn.azul.com/zulu/bin/zulu15.27.17-ca-jdk15.0.0-win_x64.zip",
         ],
-        version = "15",
     )
 
 def bazel_skylib():
diff --git a/toolchains/BUILD b/toolchains/BUILD
deleted file mode 100644
index 67d2c89..0000000
--- a/toolchains/BUILD
+++ /dev/null
@@ -1,9 +0,0 @@
-package(default_visibility = ["//visibility:public"])
-
-licenses(["notice"])
-
-filegroup(
-    name = "srcs",
-    srcs = glob(["**"]),
-    visibility = ["@//:__pkg__"],
-)
diff --git a/toolchains/remote_java_repository.bzl b/toolchains/remote_java_repository.bzl
deleted file mode 100644
index 050903c..0000000
--- a/toolchains/remote_java_repository.bzl
+++ /dev/null
@@ -1,88 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Rules for importing and registering JDKs from http archive.
-
-Rule remote_java_repository imports and registers JDK with the toolchain resolution.
-"""
-
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
-def _toolchain_config_impl(ctx):
-    ctx.file("WORKSPACE", "workspace(name = \"{name}\")\n".format(name = ctx.name))
-    ctx.file("BUILD.bazel", ctx.attr.build_file)
-
-_toolchain_config = repository_rule(
-    local = True,
-    implementation = _toolchain_config_impl,
-    attrs = {
-        "build_file": attr.string(),
-    },
-)
-
-def remote_java_repository(name, version, exec_compatible_with, prefix = "remotejdk", **kwargs):
-    """Imports and registers a JDK from a http archive.
-
-    Toolchain resolution is determined with exec_compatible_with
-    parameter and constrained with --java_runtime_version flag either having value
-    of "version" or "{prefix}_{version}" parameters.
-
-    Args:
-      name: A unique name for this rule.
-      version: Version of the JDK imported.
-      exec_compatible_with: Platform constraints (CPU and OS) for this JDK.
-      prefix: Optional alternative prefix for configuration flag value used to determine this JDK.
-      **kwargs: Refer to http_archive documentation
-    """
-    http_archive(
-        name = name,
-        build_file = "@bazel_tools//tools/jdk:jdk.BUILD",
-        **kwargs
-    )
-    _toolchain_config(
-        name = name + "_toolchain_config_repo",
-        build_file = """
-config_setting(
-    name = "prefix_version_setting",
-    values = {{"java_runtime_version": "{prefix}_{version}"}},
-    visibility = ["//visibility:private"],
-)
-config_setting(
-    name = "version_setting",
-    values = {{"java_runtime_version": "{version}"}},
-    visibility = ["//visibility:private"],
-)
-alias(
-    name = "version_or_prefix_version_setting",
-    actual = select({{
-        ":version_setting": ":version_setting",
-        "//conditions:default": ":prefix_version_setting",
-    }}),
-    visibility = ["//visibility:private"],
-)
-toolchain(
-    name = "toolchain",
-    exec_compatible_with = {exec_compatible_with},
-    target_settings = [":version_or_prefix_version_setting"],
-    toolchain_type = "@bazel_tools//tools/jdk:runtime_toolchain_type",
-    toolchain = "{toolchain}",
-)
-""".format(
-            prefix = prefix,
-            version = version,
-            exec_compatible_with = exec_compatible_with,
-            toolchain = "@{repo}//:jdk".format(repo = name),
-        ),
-    )
-    native.register_toolchains("@" + name + "_toolchain_config_repo//:toolchain")