• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 The Bazel Authors. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Development and production dependencies of rules_java."""
16
17load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
18load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
19load("//toolchains:jdk_build_file.bzl", "JDK_BUILD_TEMPLATE")
20load("//toolchains:local_java_repository.bzl", "local_java_repository")
21load("//toolchains:remote_java_repository.bzl", "remote_java_repository")
22
23# visible for tests
24JAVA_TOOLS_CONFIG = {
25    "version": "v13.13",
26    "release": "true",
27    "artifacts": {
28        "java_tools_linux": {
29            "mirror_url": "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.13/java_tools_linux-v13.13.zip",
30            "github_url": "https://github.com/bazelbuild/java_tools/releases/download/java_v13.13/java_tools_linux-v13.13.zip",
31            "sha": "60c10e91f5900801423f9c5b020cc0c7da16dbaeee9c22891b38e7017306a8e7",
32        },
33        "java_tools_windows": {
34            "mirror_url": "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.13/java_tools_windows-v13.13.zip",
35            "github_url": "https://github.com/bazelbuild/java_tools/releases/download/java_v13.13/java_tools_windows-v13.13.zip",
36            "sha": "f5de3f2afc49d1a457efa63926bcc0ca4cdb5fc4887160bf9163e49f059dd12c",
37        },
38        "java_tools_darwin_x86_64": {
39            "mirror_url": "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.13/java_tools_darwin_x86_64-v13.13.zip",
40            "github_url": "https://github.com/bazelbuild/java_tools/releases/download/java_v13.13/java_tools_darwin_x86_64-v13.13.zip",
41            "sha": "d002ff57bd5e36d6d69a1c282fa571841816a1ccc5d28060cf7fe4c7257e376a",
42        },
43        "java_tools_darwin_arm64": {
44            "mirror_url": "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.13/java_tools_darwin_arm64-v13.13.zip",
45            "github_url": "https://github.com/bazelbuild/java_tools/releases/download/java_v13.13/java_tools_darwin_arm64-v13.13.zip",
46            "sha": "6d4b4e3a12cc5fd9f600b383465d0860afd5c11ba7c7386867bb621a55fa8452",
47        },
48        "java_tools": {
49            "mirror_url": "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.13/java_tools-v13.13.zip",
50            "github_url": "https://github.com/bazelbuild/java_tools/releases/download/java_v13.13/java_tools-v13.13.zip",
51            "sha": "df895d5067f2dad4524109ebfddac442d2514d0e2f95f6abc098cfae98b9bbb5",
52            "build_file": "@rules_java//toolchains:BUILD.java_tools",
53        },
54    },
55}
56
57def java_tools_repos():
58    """ Declares the remote java_tools repositories """
59    for name, config in JAVA_TOOLS_CONFIG["artifacts"].items():
60        maybe(
61            http_archive,
62            name = "remote_" + name,
63            sha256 = config["sha"],
64            urls = [
65                config["mirror_url"],
66                config["github_url"],
67            ],
68            build_file = config.get("build_file"),
69        )
70
71def local_jdk_repo():
72    maybe(
73        local_java_repository,
74        name = "local_jdk",
75        build_file_content = JDK_BUILD_TEMPLATE,
76    )
77
78# DO NOT MANUALLY UPDATE! Update java/bazel/repositories_util.bzl instead and
79# build the java/bazel:dump_remote_jdk_configs target to generate this list
80_REMOTE_JDK_CONFIGS_LIST = [
81    struct(
82        name = "remote_jdk8_linux_aarch64",
83        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:aarch64"],
84        sha256 = "82c46c65d57e187ef68fdd125ef760eaeb52ebfe1be1a6a251cf5b43cbebc78a",
85        strip_prefix = "zulu8.78.0.19-ca-jdk8.0.412-linux_aarch64",
86        urls = ["https://cdn.azul.com/zulu/bin/zulu8.78.0.19-ca-jdk8.0.412-linux_aarch64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu8.78.0.19-ca-jdk8.0.412-linux_aarch64.tar.gz"],
87        version = "8",
88    ),
89    struct(
90        name = "remote_jdk8_linux",
91        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:x86_64"],
92        sha256 = "9c0ac5ebffa61520fee78ead52add0f4edd3b1b54b01b6a17429b719515caf90",
93        strip_prefix = "zulu8.78.0.19-ca-jdk8.0.412-linux_x64",
94        urls = ["https://cdn.azul.com/zulu/bin/zulu8.78.0.19-ca-jdk8.0.412-linux_x64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu8.78.0.19-ca-jdk8.0.412-linux_x64.tar.gz"],
95        version = "8",
96    ),
97    struct(
98        name = "remote_jdk8_macos_aarch64",
99        target_compatible_with = ["@platforms//os:macos", "@platforms//cpu:aarch64"],
100        sha256 = "35bc35808379400e4a70e1f7ee379778881799b93c2cc9fe1ae515c03c2fb057",
101        strip_prefix = "zulu8.78.0.19-ca-jdk8.0.412-macosx_aarch64",
102        urls = ["https://cdn.azul.com/zulu/bin/zulu8.78.0.19-ca-jdk8.0.412-macosx_aarch64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu8.78.0.19-ca-jdk8.0.412-macosx_aarch64.tar.gz"],
103        version = "8",
104    ),
105    struct(
106        name = "remote_jdk8_macos",
107        target_compatible_with = ["@platforms//os:macos", "@platforms//cpu:x86_64"],
108        sha256 = "2bfa0506196962bddb21a604eaa2b0b39eaf3383d0bdad08bdbe7f42f25d8928",
109        strip_prefix = "zulu8.78.0.19-ca-jdk8.0.412-macosx_x64",
110        urls = ["https://cdn.azul.com/zulu/bin/zulu8.78.0.19-ca-jdk8.0.412-macosx_x64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu8.78.0.19-ca-jdk8.0.412-macosx_x64.tar.gz"],
111        version = "8",
112    ),
113    struct(
114        name = "remote_jdk8_windows",
115        target_compatible_with = ["@platforms//os:windows", "@platforms//cpu:x86_64"],
116        sha256 = "ca5499c301d5b42604d8535b8c40a7f928a796247b8c66a600333dd799798ff7",
117        strip_prefix = "zulu8.78.0.19-ca-jdk8.0.412-win_x64",
118        urls = ["https://cdn.azul.com/zulu/bin/zulu8.78.0.19-ca-jdk8.0.412-win_x64.zip", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu8.78.0.19-ca-jdk8.0.412-win_x64.zip"],
119        version = "8",
120    ),
121    struct(
122        name = "remote_jdk8_linux_s390x",
123        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:s390x"],
124        sha256 = "276a431c79b7e94bc1b1b4fd88523383ae2d635ea67114dfc8a6174267f8fb2c",
125        strip_prefix = "jdk8u292-b10",
126        urls = ["https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_s390x_linux_hotspot_8u292b10.tar.gz", "https://mirror.bazel.build/github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_s390x_linux_hotspot_8u292b10.tar.gz"],
127        version = "8",
128    ),
129    struct(
130        name = "remotejdk11_linux_aarch64",
131        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:aarch64"],
132        sha256 = "be7d7574253c893eb58f66e985c75adf48558c41885827d1f02f827e109530e0",
133        strip_prefix = "zulu11.72.19-ca-jdk11.0.23-linux_aarch64",
134        urls = ["https://cdn.azul.com/zulu/bin/zulu11.72.19-ca-jdk11.0.23-linux_aarch64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.72.19-ca-jdk11.0.23-linux_aarch64.tar.gz"],
135        version = "11",
136    ),
137    struct(
138        name = "remotejdk11_linux",
139        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:x86_64"],
140        sha256 = "0a4d1bfc7a96a7f9f5329b72b9801b3c53366417b4753f1b658fa240204c7347",
141        strip_prefix = "zulu11.72.19-ca-jdk11.0.23-linux_x64",
142        urls = ["https://cdn.azul.com/zulu/bin/zulu11.72.19-ca-jdk11.0.23-linux_x64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.72.19-ca-jdk11.0.23-linux_x64.tar.gz"],
143        version = "11",
144    ),
145    struct(
146        name = "remotejdk11_macos_aarch64",
147        target_compatible_with = ["@platforms//os:macos", "@platforms//cpu:aarch64"],
148        sha256 = "40fb1918385e03814b67b7608c908c7f945ccbeddbbf5ed062cdfb2602e21c83",
149        strip_prefix = "zulu11.72.19-ca-jdk11.0.23-macosx_aarch64",
150        urls = ["https://cdn.azul.com/zulu/bin/zulu11.72.19-ca-jdk11.0.23-macosx_aarch64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.72.19-ca-jdk11.0.23-macosx_aarch64.tar.gz"],
151        version = "11",
152    ),
153    struct(
154        name = "remotejdk11_macos",
155        target_compatible_with = ["@platforms//os:macos", "@platforms//cpu:x86_64"],
156        sha256 = "e5b19b82045826ae09c9d17742691bc9e40312c44be7bd7598ae418a3d4edb1c",
157        strip_prefix = "zulu11.72.19-ca-jdk11.0.23-macosx_x64",
158        urls = ["https://cdn.azul.com/zulu/bin/zulu11.72.19-ca-jdk11.0.23-macosx_x64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.72.19-ca-jdk11.0.23-macosx_x64.tar.gz"],
159        version = "11",
160    ),
161    struct(
162        name = "remotejdk11_win",
163        target_compatible_with = ["@platforms//os:windows", "@platforms//cpu:x86_64"],
164        sha256 = "1295b2affe498018c45f6f15187b58c4456d51dce5eb608ee73ef7665d4566d2",
165        strip_prefix = "zulu11.72.19-ca-jdk11.0.23-win_x64",
166        urls = ["https://cdn.azul.com/zulu/bin/zulu11.72.19-ca-jdk11.0.23-win_x64.zip", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.72.19-ca-jdk11.0.23-win_x64.zip"],
167        version = "11",
168    ),
169    struct(
170        name = "remotejdk11_linux_ppc64le",
171        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:ppc"],
172        sha256 = "a8fba686f6eb8ae1d1a9566821dbd5a85a1108b96ad857fdbac5c1e4649fc56f",
173        strip_prefix = "jdk-11.0.15+10",
174        urls = ["https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.15_10.tar.gz", "https://mirror.bazel.build/github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.15_10.tar.gz"],
175        version = "11",
176    ),
177    struct(
178        name = "remotejdk11_linux_s390x",
179        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:s390x"],
180        sha256 = "a58fc0361966af0a5d5a31a2d8a208e3c9bb0f54f345596fd80b99ea9a39788b",
181        strip_prefix = "jdk-11.0.15+10",
182        urls = ["https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.15_10.tar.gz", "https://mirror.bazel.build/github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.15_10.tar.gz"],
183        version = "11",
184    ),
185    struct(
186        name = "remotejdk11_win_arm64",
187        target_compatible_with = ["@platforms//os:windows", "@platforms//cpu:arm64"],
188        sha256 = "b8a28e6e767d90acf793ea6f5bed0bb595ba0ba5ebdf8b99f395266161e53ec2",
189        strip_prefix = "jdk-11.0.13+8",
190        urls = ["https://aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-windows-aarch64.zip", "https://mirror.bazel.build/aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-windows-aarch64.zip"],
191        version = "11",
192    ),
193    struct(
194        name = "remotejdk17_linux_aarch64",
195        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:aarch64"],
196        sha256 = "518cc455c0c7b49c0ae7d809c0bb87ab371bb850d46abb8efad5010c6a06faec",
197        strip_prefix = "zulu17.50.19-ca-jdk17.0.11-linux_aarch64",
198        urls = ["https://cdn.azul.com/zulu/bin/zulu17.50.19-ca-jdk17.0.11-linux_aarch64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.50.19-ca-jdk17.0.11-linux_aarch64.tar.gz"],
199        version = "17",
200    ),
201    struct(
202        name = "remotejdk17_linux",
203        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:x86_64"],
204        sha256 = "a1e8ac9ae5804b84dc07cf9d8ebe1b18247d70c92c1e0de97ea10109563f4379",
205        strip_prefix = "zulu17.50.19-ca-jdk17.0.11-linux_x64",
206        urls = ["https://cdn.azul.com/zulu/bin/zulu17.50.19-ca-jdk17.0.11-linux_x64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.50.19-ca-jdk17.0.11-linux_x64.tar.gz"],
207        version = "17",
208    ),
209    struct(
210        name = "remotejdk17_macos_aarch64",
211        target_compatible_with = ["@platforms//os:macos", "@platforms//cpu:aarch64"],
212        sha256 = "dd1a82d57e80cdefb045066e5c28b5bd41e57eea9c57303ec7e012b57230bb9c",
213        strip_prefix = "zulu17.50.19-ca-jdk17.0.11-macosx_aarch64",
214        urls = ["https://cdn.azul.com/zulu/bin/zulu17.50.19-ca-jdk17.0.11-macosx_aarch64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.50.19-ca-jdk17.0.11-macosx_aarch64.tar.gz"],
215        version = "17",
216    ),
217    struct(
218        name = "remotejdk17_macos",
219        target_compatible_with = ["@platforms//os:macos", "@platforms//cpu:x86_64"],
220        sha256 = "b384991e93af39abe5229c7f5efbe912a7c5a6480674a6e773f3a9128f96a764",
221        strip_prefix = "zulu17.50.19-ca-jdk17.0.11-macosx_x64",
222        urls = ["https://cdn.azul.com/zulu/bin/zulu17.50.19-ca-jdk17.0.11-macosx_x64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.50.19-ca-jdk17.0.11-macosx_x64.tar.gz"],
223        version = "17",
224    ),
225    struct(
226        name = "remotejdk17_win_arm64",
227        target_compatible_with = ["@platforms//os:windows", "@platforms//cpu:arm64"],
228        sha256 = "b8833d272eb31f54f8c881139807a28a74de9deae07d2cc37688ff72043e32c9",
229        strip_prefix = "zulu17.50.19-ca-jdk17.0.11-win_aarch64",
230        urls = ["https://cdn.azul.com/zulu/bin/zulu17.50.19-ca-jdk17.0.11-win_aarch64.zip", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.50.19-ca-jdk17.0.11-win_aarch64.zip"],
231        version = "17",
232    ),
233    struct(
234        name = "remotejdk17_win",
235        target_compatible_with = ["@platforms//os:windows", "@platforms//cpu:x86_64"],
236        sha256 = "43f0f1bdecf48ba9763d46ee7784554c95b442ffdd39ebd62dc8b297cc82e116",
237        strip_prefix = "zulu17.50.19-ca-jdk17.0.11-win_x64",
238        urls = ["https://cdn.azul.com/zulu/bin/zulu17.50.19-ca-jdk17.0.11-win_x64.zip", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.50.19-ca-jdk17.0.11-win_x64.zip"],
239        version = "17",
240    ),
241    struct(
242        name = "remotejdk17_linux_ppc64le",
243        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:ppc"],
244        sha256 = "00a4c07603d0218cd678461b5b3b7e25b3253102da4022d31fc35907f21a2efd",
245        strip_prefix = "jdk-17.0.8.1+1",
246        urls = ["https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1+1/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.8.1_1.tar.gz", "https://mirror.bazel.build/github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1+1/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.8.1_1.tar.gz"],
247        version = "17",
248    ),
249    struct(
250        name = "remotejdk17_linux_s390x",
251        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:s390x"],
252        sha256 = "ffacba69c6843d7ca70d572489d6cc7ab7ae52c60f0852cedf4cf0d248b6fc37",
253        strip_prefix = "jdk-17.0.8.1+1",
254        urls = ["https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1+1/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.8.1_1.tar.gz", "https://mirror.bazel.build/github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1+1/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.8.1_1.tar.gz"],
255        version = "17",
256    ),
257    struct(
258        name = "remotejdk21_linux_aarch64",
259        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:aarch64"],
260        sha256 = "da3c2d7db33670bcf66532441aeb7f33dcf0d227c8dafe7ce35cee67f6829c4c",
261        strip_prefix = "zulu21.36.17-ca-jdk21.0.4-linux_aarch64",
262        urls = ["https://cdn.azul.com/zulu/bin/zulu21.36.17-ca-jdk21.0.4-linux_aarch64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.36.17-ca-jdk21.0.4-linux_aarch64.tar.gz"],
263        version = "21",
264    ),
265    struct(
266        name = "remotejdk21_linux",
267        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:x86_64"],
268        sha256 = "318d0c2ed3c876fb7ea2c952945cdcf7decfb5264ca51aece159e635ac53d544",
269        strip_prefix = "zulu21.36.17-ca-jdk21.0.4-linux_x64",
270        urls = ["https://cdn.azul.com/zulu/bin/zulu21.36.17-ca-jdk21.0.4-linux_x64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.36.17-ca-jdk21.0.4-linux_x64.tar.gz"],
271        version = "21",
272    ),
273    struct(
274        name = "remotejdk21_macos_aarch64",
275        target_compatible_with = ["@platforms//os:macos", "@platforms//cpu:aarch64"],
276        sha256 = "bc2750f81a166cc6e9c30ae8aaba54f253a8c8ec9d8cfc04a555fe20712c7bff",
277        strip_prefix = "zulu21.36.17-ca-jdk21.0.4-macosx_aarch64",
278        urls = ["https://cdn.azul.com/zulu/bin/zulu21.36.17-ca-jdk21.0.4-macosx_aarch64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.36.17-ca-jdk21.0.4-macosx_aarch64.tar.gz"],
279        version = "21",
280    ),
281    struct(
282        name = "remotejdk21_macos",
283        target_compatible_with = ["@platforms//os:macos", "@platforms//cpu:x86_64"],
284        sha256 = "5ce75a6a247c7029b74c4ca7cf6f60fd2b2d68ce1e8956fb448d2984316b5fea",
285        strip_prefix = "zulu21.36.17-ca-jdk21.0.4-macosx_x64",
286        urls = ["https://cdn.azul.com/zulu/bin/zulu21.36.17-ca-jdk21.0.4-macosx_x64.tar.gz", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.36.17-ca-jdk21.0.4-macosx_x64.tar.gz"],
287        version = "21",
288    ),
289    struct(
290        name = "remotejdk21_win_arm64",
291        target_compatible_with = ["@platforms//os:windows", "@platforms//cpu:arm64"],
292        sha256 = "9f873eccf030b1d3dc879ec1eb0ff5e11bf76002dc81c5c644c3462bf6c5146b",
293        strip_prefix = "zulu21.36.17-ca-jdk21.0.4-win_aarch64",
294        urls = ["https://cdn.azul.com/zulu/bin/zulu21.36.17-ca-jdk21.0.4-win_aarch64.zip", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.36.17-ca-jdk21.0.4-win_aarch64.zip"],
295        version = "21",
296    ),
297    struct(
298        name = "remotejdk21_win",
299        target_compatible_with = ["@platforms//os:windows", "@platforms//cpu:x86_64"],
300        sha256 = "d771dad10d3f0b440c3686d1f3d2b68b320802ac97b212d87671af3f2eef8848",
301        strip_prefix = "zulu21.36.17-ca-jdk21.0.4-win_x64",
302        urls = ["https://cdn.azul.com/zulu/bin/zulu21.36.17-ca-jdk21.0.4-win_x64.zip", "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.36.17-ca-jdk21.0.4-win_x64.zip"],
303        version = "21",
304    ),
305    struct(
306        name = "remotejdk21_linux_ppc64le",
307        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:ppc"],
308        sha256 = "c208cd0fb90560644a90f928667d2f53bfe408c957a5e36206585ad874427761",
309        strip_prefix = "jdk-21.0.4+7",
310        urls = ["https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.4+7/OpenJDK21U-jdk_ppc64le_linux_hotspot_21.0.4_7.tar.gz", "https://mirror.bazel.build/github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.4+7/OpenJDK21U-jdk_ppc64le_linux_hotspot_21.0.4_7.tar.gz"],
311        version = "21",
312    ),
313    struct(
314        name = "remotejdk21_linux_s390x",
315        target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:s390x"],
316        sha256 = "c900c8d64fab1e53274974fa4a4c736a5a3754485a5c56f4947281480773658a",
317        strip_prefix = "jdk-21.0.4+7",
318        urls = ["https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.4+7/OpenJDK21U-jdk_s390x_linux_hotspot_21.0.4_7.tar.gz", "https://mirror.bazel.build/github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.4+7/OpenJDK21U-jdk_s390x_linux_hotspot_21.0.4_7.tar.gz"],
319        version = "21",
320    ),
321]
322
323def _make_version_to_remote_jdks():
324    result = {}
325    for cfg in _REMOTE_JDK_CONFIGS_LIST:
326        result.setdefault(cfg.version, [])
327        result[cfg.version].append(cfg)
328    return result
329
330# visible for testing
331REMOTE_JDK_CONFIGS = _make_version_to_remote_jdks()
332
333def _remote_jdk_repos_for_version(version):
334    for item in REMOTE_JDK_CONFIGS[version]:
335        maybe(
336            remote_java_repository,
337            name = item.name,
338            target_compatible_with = item.target_compatible_with,
339            sha256 = item.sha256,
340            strip_prefix = item.strip_prefix,
341            urls = item.urls,
342            version = item.version,
343        )
344
345def remote_jdk8_repos(name = ""):
346    """Imports OpenJDK 8 repositories.
347
348    Args:
349        name: The name of this macro (not used)
350    """
351    _remote_jdk_repos_for_version("8")
352
353def remote_jdk11_repos():
354    """Imports OpenJDK 11 repositories."""
355    _remote_jdk_repos_for_version("11")
356
357def remote_jdk17_repos():
358    """Imports OpenJDK 17 repositories."""
359    _remote_jdk_repos_for_version("17")
360
361def remote_jdk21_repos():
362    """Imports OpenJDK 21 repositories."""
363    _remote_jdk_repos_for_version("21")
364
365def rules_java_dependencies():
366    """DEPRECATED: No-op, kept for backwards compatibility"""
367    print("DEPRECATED: use rules_java_dependencies() from rules_java_deps.bzl")  # buildifier: disable=print
368
369def rules_java_toolchains(name = "toolchains"):
370    """An utility method to load all Java toolchains.
371
372    Args:
373        name: The name of this macro (not used)
374    """
375    local_jdk_repo()
376    remote_jdk8_repos()
377    remote_jdk11_repos()
378    remote_jdk17_repos()
379    remote_jdk21_repos()
380    java_tools_repos()
381
382    native.register_toolchains(
383        "//toolchains:all",
384        "@local_jdk//:runtime_toolchain_definition",
385        "@local_jdk//:bootstrap_runtime_toolchain_definition",
386    )
387    for items in REMOTE_JDK_CONFIGS.values():
388        for item in items:
389            native.register_toolchains(
390                "@" + item.name + "_toolchain_config_repo//:toolchain",
391                "@" + item.name + "_toolchain_config_repo//:bootstrap_runtime_toolchain",
392            )
393