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_JAVA_TOOLS_CONFIG = { 24 "version": "v13.6.0", 25 "release": "true", 26 "artifacts": { 27 "java_tools_linux": { 28 "mirror_url": "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.6.0/java_tools_linux-v13.6.0.zip", 29 "github_url": "https://github.com/bazelbuild/java_tools/releases/download/java_v13.6.0/java_tools_linux-v13.6.0.zip", 30 "sha": "0d3fcae7ae40d0a25f17c3adc30a3674f526953c55871189e2efe3463fce3496", 31 }, 32 "java_tools_windows": { 33 "mirror_url": "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.6.0/java_tools_windows-v13.6.0.zip", 34 "github_url": "https://github.com/bazelbuild/java_tools/releases/download/java_v13.6.0/java_tools_windows-v13.6.0.zip", 35 "sha": "5a7d00e42c0b35f08eb5c8577eb115f8f57dd36ef8b6940c2190bd0d0e4ddcf0", 36 }, 37 "java_tools_darwin_x86_64": { 38 "mirror_url": "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.6.0/java_tools_darwin_x86_64-v13.6.0.zip", 39 "github_url": "https://github.com/bazelbuild/java_tools/releases/download/java_v13.6.0/java_tools_darwin_x86_64-v13.6.0.zip", 40 "sha": "465dcb1da77a0c83c49f178c11bad29b3d703df1756722ec42fe5afd7c8129f8", 41 }, 42 "java_tools_darwin_arm64": { 43 "mirror_url": "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.6.0/java_tools_darwin_arm64-v13.6.0.zip", 44 "github_url": "https://github.com/bazelbuild/java_tools/releases/download/java_v13.6.0/java_tools_darwin_arm64-v13.6.0.zip", 45 "sha": "eb54c4e5fa23d6e9e9fc14c106a682dbefc54659d8e389a2f3c0d61d51cae274", 46 }, 47 "java_tools": { 48 "mirror_url": "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.6.0/java_tools-v13.6.0.zip", 49 "github_url": "https://github.com/bazelbuild/java_tools/releases/download/java_v13.6.0/java_tools-v13.6.0.zip", 50 "sha": "74c978eab040ad4ec38ce0d0970ac813cc2c6f4f6f4f121c0414719487edc991", 51 }, 52 }, 53} 54 55def java_tools_repos(): 56 """ Declares the remote java_tools repositories """ 57 for name, config in _JAVA_TOOLS_CONFIG["artifacts"].items(): 58 maybe( 59 http_archive, 60 name = "remote_" + name, 61 sha256 = config["sha"], 62 urls = [ 63 config["mirror_url"], 64 config["github_url"], 65 ], 66 ) 67 68def local_jdk_repo(): 69 maybe( 70 local_java_repository, 71 name = "local_jdk", 72 build_file_content = JDK_BUILD_TEMPLATE, 73 ) 74 75def remote_jdk8_repos(name = ""): 76 """Imports OpenJDK 8 repositories. 77 78 Args: 79 name: The name of this macro (not used) 80 """ 81 maybe( 82 remote_java_repository, 83 name = "remote_jdk8_linux_aarch64", 84 target_compatible_with = [ 85 "@platforms//os:linux", 86 "@platforms//cpu:aarch64", 87 ], 88 sha256 = "f4072e82faa5a09fab2accf2892d4684324fc999d614583c3ff785e87c03963f", 89 strip_prefix = "zulu8.50.51.263-ca-jdk8.0.275-linux_aarch64", 90 urls = [ 91 "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", 92 "https://cdn.azul.com/zulu-embedded/bin/zulu8.50.51.263-ca-jdk8.0.275-linux_aarch64.tar.gz", 93 ], 94 version = "8", 95 ) 96 maybe( 97 remote_java_repository, 98 name = "remote_jdk8_linux_s390x", 99 target_compatible_with = [ 100 "@platforms//os:linux", 101 "@platforms//cpu:s390x", 102 ], 103 sha256 = "276a431c79b7e94bc1b1b4fd88523383ae2d635ea67114dfc8a6174267f8fb2c", 104 strip_prefix = "jdk8u292-b10", 105 urls = [ 106 "https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_s390x_linux_hotspot_8u292b10.tar.gz", 107 ], 108 version = "8", 109 ) 110 maybe( 111 remote_java_repository, 112 name = "remote_jdk8_linux", 113 target_compatible_with = [ 114 "@platforms//os:linux", 115 "@platforms//cpu:x86_64", 116 ], 117 sha256 = "1db6b2fa642950ee1b4b1ec2b6bc8a9113d7a4cd723f79398e1ada7dab1c981c", 118 strip_prefix = "zulu8.50.0.51-ca-jdk8.0.275-linux_x64", 119 urls = [ 120 "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", 121 "https://cdn.azul.com/zulu/bin/zulu8.50.0.51-ca-jdk8.0.275-linux_x64.tar.gz", 122 ], 123 version = "8", 124 ) 125 maybe( 126 remote_java_repository, 127 name = "remote_jdk8_macos_aarch64", 128 target_compatible_with = [ 129 "@platforms//os:macos", 130 "@platforms//cpu:aarch64", 131 ], 132 sha256 = "e5c84a46bbd985c3a53358db9c97a6fd4930f92b833c3163a0d1e47dab59768c", 133 strip_prefix = "zulu8.62.0.19-ca-jdk8.0.332-macosx_aarch64", 134 urls = [ 135 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu8.62.0.19-ca-jdk8.0.332-macosx_aarch64.tar.gz", 136 "https://cdn.azul.com/zulu/bin/zulu8.62.0.19-ca-jdk8.0.332-macosx_aarch64.tar.gz", 137 ], 138 version = "8", 139 ) 140 maybe( 141 remote_java_repository, 142 name = "remote_jdk8_macos", 143 target_compatible_with = [ 144 "@platforms//os:macos", 145 "@platforms//cpu:x86_64", 146 ], 147 sha256 = "b03176597734299c9a15b7c2cc770783cf14d121196196c1248e80c026b59c17", 148 strip_prefix = "zulu8.50.0.51-ca-jdk8.0.275-macosx_x64", 149 urls = [ 150 "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", 151 "https://cdn.azul.com/zulu/bin/zulu8.50.0.51-ca-jdk8.0.275-macosx_x64.tar.gz", 152 ], 153 version = "8", 154 ) 155 maybe( 156 remote_java_repository, 157 name = "remote_jdk8_windows", 158 target_compatible_with = [ 159 "@platforms//os:windows", 160 "@platforms//cpu:x86_64", 161 ], 162 sha256 = "49759b2bd2ab28231a21ff3a3bb45824ddef55d89b5b1a05a62e26a365da0774", 163 strip_prefix = "zulu8.50.0.51-ca-jdk8.0.275-win_x64", 164 urls = [ 165 "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", 166 "https://cdn.azul.com/zulu/bin/zulu8.50.0.51-ca-jdk8.0.275-win_x64.zip", 167 ], 168 version = "8", 169 ) 170 171def remote_jdk11_repos(): 172 """Imports OpenJDK 11 repositories.""" 173 maybe( 174 remote_java_repository, 175 name = "remotejdk11_linux", 176 target_compatible_with = [ 177 "@platforms//os:linux", 178 "@platforms//cpu:x86_64", 179 ], 180 sha256 = "a34b404f87a08a61148b38e1416d837189e1df7a040d949e743633daf4695a3c", 181 strip_prefix = "zulu11.66.15-ca-jdk11.0.20-linux_x64", 182 urls = [ 183 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_x64.tar.gz", 184 "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_x64.tar.gz", 185 ], 186 version = "11", 187 ) 188 189 maybe( 190 remote_java_repository, 191 name = "remotejdk11_linux_aarch64", 192 target_compatible_with = [ 193 "@platforms//os:linux", 194 "@platforms//cpu:aarch64", 195 ], 196 sha256 = "54174439f2b3fddd11f1048c397fe7bb45d4c9d66d452d6889b013d04d21c4de", 197 strip_prefix = "zulu11.66.15-ca-jdk11.0.20-linux_aarch64", 198 urls = [ 199 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_aarch64.tar.gz", 200 "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_aarch64.tar.gz", 201 ], 202 version = "11", 203 ) 204 205 maybe( 206 remote_java_repository, 207 name = "remotejdk11_linux_ppc64le", 208 target_compatible_with = [ 209 "@platforms//os:linux", 210 "@platforms//cpu:ppc", 211 ], 212 sha256 = "a8fba686f6eb8ae1d1a9566821dbd5a85a1108b96ad857fdbac5c1e4649fc56f", 213 strip_prefix = "jdk-11.0.15+10", 214 urls = [ 215 "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", 216 "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.15_10.tar.gz", 217 ], 218 version = "11", 219 ) 220 221 maybe( 222 remote_java_repository, 223 name = "remotejdk11_linux_s390x", 224 target_compatible_with = [ 225 "@platforms//os:linux", 226 "@platforms//cpu:s390x", 227 ], 228 sha256 = "a58fc0361966af0a5d5a31a2d8a208e3c9bb0f54f345596fd80b99ea9a39788b", 229 strip_prefix = "jdk-11.0.15+10", 230 urls = [ 231 "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", 232 "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.15_10.tar.gz", 233 ], 234 version = "11", 235 ) 236 237 maybe( 238 remote_java_repository, 239 name = "remotejdk11_macos", 240 target_compatible_with = [ 241 "@platforms//os:macos", 242 "@platforms//cpu:x86_64", 243 ], 244 sha256 = "bcaab11cfe586fae7583c6d9d311c64384354fb2638eb9a012eca4c3f1a1d9fd", 245 strip_prefix = "zulu11.66.15-ca-jdk11.0.20-macosx_x64", 246 urls = [ 247 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_x64.tar.gz", 248 "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_x64.tar.gz", 249 ], 250 version = "11", 251 ) 252 253 maybe( 254 remote_java_repository, 255 name = "remotejdk11_macos_aarch64", 256 target_compatible_with = [ 257 "@platforms//os:macos", 258 "@platforms//cpu:aarch64", 259 ], 260 sha256 = "7632bc29f8a4b7d492b93f3bc75a7b61630894db85d136456035ab2a24d38885", 261 strip_prefix = "zulu11.66.15-ca-jdk11.0.20-macosx_aarch64", 262 urls = [ 263 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_aarch64.tar.gz", 264 "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_aarch64.tar.gz", 265 ], 266 version = "11", 267 ) 268 269 maybe( 270 remote_java_repository, 271 name = "remotejdk11_win", 272 target_compatible_with = [ 273 "@platforms//os:windows", 274 "@platforms//cpu:x86_64", 275 ], 276 sha256 = "43408193ce2fa0862819495b5ae8541085b95660153f2adcf91a52d3a1710e83", 277 strip_prefix = "zulu11.66.15-ca-jdk11.0.20-win_x64", 278 urls = [ 279 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-win_x64.zip", 280 "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-win_x64.zip", 281 ], 282 version = "11", 283 ) 284 285 maybe( 286 remote_java_repository, 287 name = "remotejdk11_win_arm64", 288 target_compatible_with = [ 289 "@platforms//os:windows", 290 "@platforms//cpu:arm64", 291 ], 292 sha256 = "b8a28e6e767d90acf793ea6f5bed0bb595ba0ba5ebdf8b99f395266161e53ec2", 293 strip_prefix = "jdk-11.0.13+8", 294 urls = [ 295 "https://mirror.bazel.build/aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-windows-aarch64.zip", 296 ], 297 version = "11", 298 ) 299 300def remote_jdk17_repos(): 301 """Imports OpenJDK 17 repositories.""" 302 maybe( 303 remote_java_repository, 304 name = "remotejdk17_linux", 305 target_compatible_with = [ 306 "@platforms//os:linux", 307 "@platforms//cpu:x86_64", 308 ], 309 sha256 = "b9482f2304a1a68a614dfacddcf29569a72f0fac32e6c74f83dc1b9a157b8340", 310 strip_prefix = "zulu17.44.53-ca-jdk17.0.8.1-linux_x64", 311 urls = [ 312 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_x64.tar.gz", 313 "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_x64.tar.gz", 314 ], 315 version = "17", 316 ) 317 318 maybe( 319 remote_java_repository, 320 name = "remotejdk17_linux_aarch64", 321 target_compatible_with = [ 322 "@platforms//os:linux", 323 "@platforms//cpu:aarch64", 324 ], 325 sha256 = "6531cef61e416d5a7b691555c8cf2bdff689201b8a001ff45ab6740062b44313", 326 strip_prefix = "zulu17.44.53-ca-jdk17.0.8.1-linux_aarch64", 327 urls = [ 328 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_aarch64.tar.gz", 329 "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_aarch64.tar.gz", 330 ], 331 version = "17", 332 ) 333 334 maybe( 335 remote_java_repository, 336 name = "remotejdk17_linux_s390x", 337 target_compatible_with = [ 338 "@platforms//os:linux", 339 "@platforms//cpu:s390x", 340 ], 341 sha256 = "ffacba69c6843d7ca70d572489d6cc7ab7ae52c60f0852cedf4cf0d248b6fc37", 342 strip_prefix = "jdk-17.0.8.1+1", 343 urls = [ 344 "https://mirror.bazel.build/github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.8.1_1.tar.gz", 345 "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.8.1_1.tar.gz", 346 ], 347 version = "17", 348 ) 349 350 maybe( 351 remote_java_repository, 352 name = "remotejdk17_linux_ppc64le", 353 target_compatible_with = [ 354 "@platforms//os:linux", 355 "@platforms//cpu:ppc", 356 ], 357 sha256 = "00a4c07603d0218cd678461b5b3b7e25b3253102da4022d31fc35907f21a2efd", 358 strip_prefix = "jdk-17.0.8.1+1", 359 urls = [ 360 "https://mirror.bazel.build/github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.8.1_1.tar.gz", 361 "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.8.1_1.tar.gz", 362 ], 363 version = "17", 364 ) 365 366 maybe( 367 remote_java_repository, 368 name = "remotejdk17_macos", 369 target_compatible_with = [ 370 "@platforms//os:macos", 371 "@platforms//cpu:x86_64", 372 ], 373 sha256 = "640453e8afe8ffe0fb4dceb4535fb50db9c283c64665eebb0ba68b19e65f4b1f", 374 strip_prefix = "zulu17.44.53-ca-jdk17.0.8.1-macosx_x64", 375 urls = [ 376 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_x64.tar.gz", 377 "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_x64.tar.gz", 378 ], 379 version = "17", 380 ) 381 382 maybe( 383 remote_java_repository, 384 name = "remotejdk17_macos_aarch64", 385 target_compatible_with = [ 386 "@platforms//os:macos", 387 "@platforms//cpu:aarch64", 388 ], 389 sha256 = "314b04568ec0ae9b36ba03c9cbd42adc9e1265f74678923b19297d66eb84dcca", 390 strip_prefix = "zulu17.44.53-ca-jdk17.0.8.1-macosx_aarch64", 391 urls = [ 392 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_aarch64.tar.gz", 393 "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_aarch64.tar.gz", 394 ], 395 version = "17", 396 ) 397 maybe( 398 remote_java_repository, 399 name = "remotejdk17_win", 400 target_compatible_with = [ 401 "@platforms//os:windows", 402 "@platforms//cpu:x86_64", 403 ], 404 sha256 = "192f2afca57701de6ec496234f7e45d971bf623ff66b8ee4a5c81582054e5637", 405 strip_prefix = "zulu17.44.53-ca-jdk17.0.8.1-win_x64", 406 urls = [ 407 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_x64.zip", 408 "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_x64.zip", 409 ], 410 version = "17", 411 ) 412 maybe( 413 remote_java_repository, 414 name = "remotejdk17_win_arm64", 415 target_compatible_with = [ 416 "@platforms//os:windows", 417 "@platforms//cpu:arm64", 418 ], 419 sha256 = "6802c99eae0d788e21f52d03cab2e2b3bf42bc334ca03cbf19f71eb70ee19f85", 420 strip_prefix = "zulu17.44.53-ca-jdk17.0.8.1-win_aarch64", 421 urls = [ 422 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_aarch64.zip", 423 "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_aarch64.zip", 424 ], 425 version = "17", 426 ) 427 428def remote_jdk21_repos(): 429 """Imports OpenJDK 21 repositories.""" 430 maybe( 431 remote_java_repository, 432 name = "remotejdk21_linux", 433 target_compatible_with = [ 434 "@platforms//os:linux", 435 "@platforms//cpu:x86_64", 436 ], 437 sha256 = "5ad730fbee6bb49bfff10bf39e84392e728d89103d3474a7e5def0fd134b300a", 438 strip_prefix = "zulu21.32.17-ca-jdk21.0.2-linux_x64", 439 urls = [ 440 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_x64.tar.gz", 441 "https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_x64.tar.gz", 442 ], 443 version = "21", 444 ) 445 maybe( 446 remote_java_repository, 447 name = "remotejdk21_linux_aarch64", 448 target_compatible_with = [ 449 "@platforms//os:linux", 450 "@platforms//cpu:aarch64", 451 ], 452 sha256 = "ce7df1af5d44a9f455617c4b8891443fbe3e4b269c777d8b82ed66f77167cfe0", 453 strip_prefix = "zulu21.32.17-ca-jdk21.0.2-linux_aarch64", 454 urls = [ 455 "https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_aarch64.tar.gz", 456 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_aarch64.tar.gz", 457 ], 458 version = "21", 459 ) 460 maybe( 461 remote_java_repository, 462 name = "remotejdk21_linux_ppc64le", 463 target_compatible_with = [ 464 "@platforms//os:linux", 465 "@platforms//cpu:ppc", 466 ], 467 sha256 = "d08de863499d8851811c893e8915828f2cd8eb67ed9e29432a6b4e222d80a12f", 468 strip_prefix = "jdk-21.0.2+13", 469 urls = [ 470 "https://mirror.bazel.build/github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jdk_ppc64le_linux_hotspot_21.0.2_13.tar.gz", 471 "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jdk_ppc64le_linux_hotspot_21.0.2_13.tar.gz", 472 ], 473 version = "21", 474 ) 475 maybe( 476 remote_java_repository, 477 name = "remotejdk21_linux_s390x", 478 target_compatible_with = [ 479 "@platforms//os:linux", 480 "@platforms//cpu:s390x", 481 ], 482 sha256 = "0d5676c50821e0d0b951bf3ffd717e7a13be2a89d8848a5c13b4aedc6f982c78", 483 strip_prefix = "jdk-21.0.2+13", 484 urls = [ 485 "https://mirror.bazel.build/github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jdk_s390x_linux_hotspot_21.0.2_13.tar.gz", 486 "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jdk_s390x_linux_hotspot_21.0.2_13.tar.gz", 487 ], 488 version = "21", 489 ) 490 maybe( 491 remote_java_repository, 492 name = "remotejdk21_macos", 493 target_compatible_with = [ 494 "@platforms//os:macos", 495 "@platforms//cpu:x86_64", 496 ], 497 sha256 = "3ad8fe288eb57d975c2786ae453a036aa46e47ab2ac3d81538ebae2a54d3c025", 498 strip_prefix = "zulu21.32.17-ca-jdk21.0.2-macosx_x64", 499 urls = [ 500 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-macosx_x64.tar.gz", 501 "https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-macosx_x64.tar.gz", 502 ], 503 version = "21", 504 ) 505 506 maybe( 507 remote_java_repository, 508 name = "remotejdk21_macos_aarch64", 509 target_compatible_with = [ 510 "@platforms//os:macos", 511 "@platforms//cpu:aarch64", 512 ], 513 sha256 = "e8260516de8b60661422a725f1df2c36ef888f6fb35393566b00e7325db3d04e", 514 strip_prefix = "zulu21.32.17-ca-jdk21.0.2-macosx_aarch64", 515 urls = [ 516 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-macosx_aarch64.tar.gz", 517 "https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-macosx_aarch64.tar.gz", 518 ], 519 version = "21", 520 ) 521 maybe( 522 remote_java_repository, 523 name = "remotejdk21_win", 524 target_compatible_with = [ 525 "@platforms//os:windows", 526 "@platforms//cpu:x86_64", 527 ], 528 sha256 = "f7cc15ca17295e69c907402dfe8db240db446e75d3b150da7bf67243cded93de", 529 strip_prefix = "zulu21.32.17-ca-jdk21.0.2-win_x64", 530 urls = [ 531 "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-win_x64.zip", 532 "https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-win_x64.zip", 533 ], 534 version = "21", 535 ) 536 maybe( 537 remote_java_repository, 538 name = "remotejdk21_win_arm64", 539 target_compatible_with = [ 540 "@platforms//os:windows", 541 "@platforms//cpu:arm64", 542 ], 543 sha256 = "975603e684f2ec5a525b3b5336d6aa0b09b5b7d2d0d9e271bd6a9892ad550181", 544 strip_prefix = "jdk-21+35", 545 urls = [ 546 "https://mirror.bazel.build/aka.ms/download-jdk/microsoft-jdk-21.0.0-windows-aarch64.zip", 547 "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-windows-aarch64.zip", 548 ], 549 version = "21", 550 ) 551 552def rules_java_dependencies(): 553 """An utility method to load all dependencies of rules_java. 554 555 Loads the remote repositories used by default in Bazel. 556 """ 557 558 local_jdk_repo() 559 remote_jdk8_repos() 560 remote_jdk11_repos() 561 remote_jdk17_repos() 562 remote_jdk21_repos() 563 java_tools_repos() 564 565def rules_java_toolchains(name = "toolchains"): 566 """An utility method to load all Java toolchains. 567 568 Args: 569 name: The name of this macro (not used) 570 """ 571 JDKS = { 572 # Must match JDK repos defined in remote_jdk8_repos() 573 "8": ["linux", "linux_aarch64", "linux_s390x", "macos", "macos_aarch64", "windows"], 574 # Must match JDK repos defined in remote_jdk11_repos() 575 "11": ["linux", "linux_aarch64", "linux_ppc64le", "linux_s390x", "macos", "macos_aarch64", "win", "win_arm64"], 576 # Must match JDK repos defined in remote_jdk17_repos() 577 "17": ["linux", "linux_aarch64", "linux_ppc64le", "linux_s390x", "macos", "macos_aarch64", "win", "win_arm64"], 578 # Must match JDK repos defined in remote_jdk21_repos() 579 "21": ["linux", "linux_aarch64", "macos", "macos_aarch64", "win"], 580 } 581 582 REMOTE_JDK_REPOS = [(("remote_jdk" if version == "8" else "remotejdk") + version + "_" + platform) for version in JDKS for platform in JDKS[version]] 583 584 native.register_toolchains( 585 "//toolchains:all", 586 "@local_jdk//:runtime_toolchain_definition", 587 "@local_jdk//:bootstrap_runtime_toolchain_definition", 588 ) 589 for name in REMOTE_JDK_REPOS: 590 native.register_toolchains( 591 "@" + name + "_toolchain_config_repo//:toolchain", 592 "@" + name + "_toolchain_config_repo//:bootstrap_runtime_toolchain", 593 ) 594