From 9ed9221129c53ff610a7494ddd583b17c7d8ce43 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Sat, 25 Sep 2021 19:40:44 -0700 Subject: [PATCH] Add a Java 17 toolchain https://github.com/bazelbuild/bazel/issues/13965 --- WORKSPACE | 124 +++++++++++++++ src/BUILD | 8 + .../lib/bazel/rules/java/jdk.WORKSPACE.tmpl | 72 +++++++++ src/test/py/bazel/test_base.py | 4 + src/test/shell/bazel/BUILD | 20 ++- src/test/shell/bazel/bazel_java17_test.sh | 148 ++++++++++++++++++ .../bazel/testdata/jdk_http_archives.tmpl | 65 ++++++++ src/test/shell/testenv.sh.tmpl | 8 + src/upload_all_java_tools.sh | 2 +- tools/jdk/BUILD.tools | 19 +++ 10 files changed, 468 insertions(+), 2 deletions(-) create mode 100755 src/test/shell/bazel/bazel_java17_test.sh diff --git a/WORKSPACE b/WORKSPACE index 6bff973b0da4ee..4af5f99ad25adf 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -679,6 +679,66 @@ http_archive( ], ) +# This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE. +http_archive( + name = "remotejdk17_linux_for_testing", + build_file = "@local_jdk//:BUILD.bazel", + patch_cmds = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE, + patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE_WIN, + sha256 = "37c4f8e48536cceae8c6c20250d6c385e176972532fd35759fa7d6015c965f56", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-linux_x64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-linux_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-linux_x64.tar.gz", + ], +) + +# This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE. +http_archive( + name = "remotejdk17_macos_for_testing", + build_file = "@local_jdk//:BUILD.bazel", + patch_cmds = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE, + patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE_WIN, + sha256 = "6029b1fe6853cecad22ab99ac0b3bb4fb8c903dd2edefa91c3abc89755bbd47d", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-macosx_x64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_x64.tar.gz", + ], +) + +# This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE. +http_archive( + name = "remotejdk17_macos_aarch64_for_testing", + build_file = "@local_jdk//:BUILD.bazel", + patch_cmds = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE, + patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE_WIN, + sha256 = "6b17f01f767ee7abf4704149ca4d86423aab9b16b68697b7d36e9b616846a8b0", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-macosx_aarch64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_aarch64.tar.gz", + ], +) + +# This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE. +http_archive( + name = "remotejdk17_win_for_testing", + build_file = "@local_jdk//:BUILD.bazel", + patch_cmds = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE, + patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE_WIN, + sha256 = "f4437011239f3f0031c794bb91c02a6350bc941d4196bdd19c9f157b491815a3", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-win_x64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-win_x64.zip", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-win_x64.zip", + ], +) + # Used in src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE. dist_http_archive( name = "remote_java_tools_for_testing", @@ -906,6 +966,70 @@ exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) ], ) +# This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives. +http_archive( + name = "openjdk17_linux_archive", + build_file_content = """ +java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public']) +exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) +""", + sha256 = "37c4f8e48536cceae8c6c20250d6c385e176972532fd35759fa7d6015c965f56", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-linux_x64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-linux_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-linux_x64.tar.gz", + ], +) + +# This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives. +http_archive( + name = "openjdk17_darwin_archive", + build_file_content = """ +java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public']) +exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) +""", + sha256 = "6029b1fe6853cecad22ab99ac0b3bb4fb8c903dd2edefa91c3abc89755bbd47d", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-macosx_x64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_x64.tar.gz", + ], +) + +# This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives. +http_archive( + name = "openjdk17_darwin_aarch64_archive", + build_file_content = """ +java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public']) +exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) +""", + sha256 = "6b17f01f767ee7abf4704149ca4d86423aab9b16b68697b7d36e9b616846a8b0", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-macosx_aarch64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_aarch64.tar.gz", + ], +) + +# This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives. +http_archive( + name = "openjdk17_windows_archive", + build_file_content = """ +java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public']) +exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) +""", + sha256 = "f4437011239f3f0031c794bb91c02a6350bc941d4196bdd19c9f157b491815a3", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-win_x64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-win_x64.zip", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-win_x64.zip", + ], +) + load("@io_bazel_skydoc//:setup.bzl", "stardoc_repositories") stardoc_repositories() diff --git a/src/BUILD b/src/BUILD index 9efefacc31463d..8fdcf5b0637349 100644 --- a/src/BUILD +++ b/src/BUILD @@ -657,6 +657,10 @@ filegroup( "@openjdk16_darwin_archive//:WORKSPACE", "@openjdk16_linux_archive//:WORKSPACE", "@openjdk16_windows_archive//:WORKSPACE", + "@openjdk17_darwin_aarch64_archive//:WORKSPACE", + "@openjdk17_darwin_archive//:WORKSPACE", + "@openjdk17_linux_archive//:WORKSPACE", + "@openjdk17_windows_archive//:WORKSPACE", "@openjdk_linux_aarch64_minimal//file", "@openjdk_linux_minimal//file", "@openjdk_macos_aarch64_minimal//file", @@ -686,6 +690,10 @@ filegroup( "@remotejdk16_macos_aarch64_for_testing//:WORKSPACE", "@remotejdk16_macos_for_testing//:WORKSPACE", "@remotejdk16_win_for_testing//:WORKSPACE", + "@remotejdk17_linux_for_testing//:WORKSPACE", + "@remotejdk17_macos_aarch64_for_testing//:WORKSPACE", + "@remotejdk17_macos_for_testing//:WORKSPACE", + "@remotejdk17_win_for_testing//:WORKSPACE", "@rules_cc//:WORKSPACE", "@rules_java//:WORKSPACE", "@rules_pkg//:WORKSPACE", diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl index 3f502e189aba7c..8db9e47c9d792e 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.tmpl @@ -268,6 +268,78 @@ maybe( version = "16", ) +# This must be kept in sync with the top-level WORKSPACE file. +maybe( + remote_java_repository, + name = "remotejdk17_linux", + exec_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ], + sha256 = "37c4f8e48536cceae8c6c20250d6c385e176972532fd35759fa7d6015c965f56", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-linux_x64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-linux_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-linux_x64.tar.gz", + ], + version = "17", +) + +# This must be kept in sync with the top-level WORKSPACE file. +maybe( + remote_java_repository, + name = "remotejdk17_macos", + exec_compatible_with = [ + "@platforms//os:macos", + "@platforms//cpu:x86_64", + ], + sha256 = "6029b1fe6853cecad22ab99ac0b3bb4fb8c903dd2edefa91c3abc89755bbd47d", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-macosx_x64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_x64.tar.gz", + ], + version = "17", +) + +# This must be kept in sync with the top-level WORKSPACE file. +maybe( + remote_java_repository, + name = "remotejdk17_macos_aarch64", + exec_compatible_with = [ + "@platforms//os:macos", + "@platforms//cpu:aarch64", + ], + sha256 = "6b17f01f767ee7abf4704149ca4d86423aab9b16b68697b7d36e9b616846a8b0", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-macosx_aarch64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_aarch64.tar.gz", + ], + version = "17", +) + +# This must be kept in sync with the top-level WORKSPACE file. +maybe( + remote_java_repository, + name = "remotejdk17_win", + exec_compatible_with = [ + "@platforms//os:windows", + "@platforms//cpu:x86_64", + ], + sha256 = "f4437011239f3f0031c794bb91c02a6350bc941d4196bdd19c9f157b491815a3", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-win_x64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-win_x64.zip", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-win_x64.zip", + ], + version = "17", +) + {remote_java_tools} {remote_java_tools_linux} {remote_java_tools_windows} diff --git a/src/test/py/bazel/test_base.py b/src/test/py/bazel/test_base.py index 23a878ed0722b6..f980f8fd85b3ee 100644 --- a/src/test/py/bazel/test_base.py +++ b/src/test/py/bazel/test_base.py @@ -72,6 +72,10 @@ class TestBase(unittest.TestCase): 'remotejdk16_macos_for_testing', 'remotejdk16_macos_aarch64_for_testing', 'remotejdk16_win_for_testing', + 'remotejdk17_linux_for_testing', + 'remotejdk17_macos_for_testing', + 'remotejdk17_macos_aarch64_for_testing', + 'remotejdk17_win_for_testing', 'remote_java_tools_for_testing', 'remote_java_tools_darwin_for_testing', 'remote_java_tools_linux_for_testing', diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD index f219a44f5b9cf2..6fd0acf47ba61c 100644 --- a/src/test/shell/bazel/BUILD +++ b/src/test/shell/bazel/BUILD @@ -223,6 +223,24 @@ sh_test( tags = ["local"], ) +sh_test( + name = "bazel_java17_test", + srcs = ["bazel_java17_test.sh"], + args = [ + # java_tools zip to test + "src/java_tools.zip", + "src/java_tools_prebuilt.zip", + ], + data = [ + ":test-deps", + "//src:java_tools_prebuilt_zip", + "//src:java_tools_zip", + "//src/test/shell/bazel/testdata:jdk_http_archives_filegroup", + "@bazel_tools//tools/bash/runfiles", + ], + tags = ["local"], +) + sh_test( name = "bazel_java_test", # TODO(iirina): Investigate if the 'large' and 'eternal' values still apply. @@ -241,7 +259,7 @@ sh_test( exec_compatible_with = ["//:highcpu_machine"], ) -JAVA_VERSIONS = ("11", "15", "16") +JAVA_VERSIONS = ("11", "15", "16", "17") # TODO(davido): Enable test coverage for JDK 16 toolchain when this issue is fixed: # https://github.com/bazelbuild/bazel/issues/13358 diff --git a/src/test/shell/bazel/bazel_java17_test.sh b/src/test/shell/bazel/bazel_java17_test.sh new file mode 100755 index 00000000000000..74cc8622dc0189 --- /dev/null +++ b/src/test/shell/bazel/bazel_java17_test.sh @@ -0,0 +1,148 @@ +#!/bin/bash +# +# Copyright 2021 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. +# +# Tests that bazel runs projects with Java 17 features. + +# --- begin runfiles.bash initialization --- +if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then + if [[ -f "$0.runfiles_manifest" ]]; then + export RUNFILES_MANIFEST_FILE="$0.runfiles_manifest" + elif [[ -f "$0.runfiles/MANIFEST" ]]; then + export RUNFILES_MANIFEST_FILE="$0.runfiles/MANIFEST" + elif [[ -f "$0.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then + export RUNFILES_DIR="$0.runfiles" + fi +fi +if [[ -f "${RUNFILES_DIR:-/dev/null}/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then + source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash" +elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then + source "$(grep -m1 "^bazel_tools/tools/bash/runfiles/runfiles.bash " \ + "$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)" +else + echo >&2 "ERROR: cannot find @bazel_tools//tools/bash/runfiles:runfiles.bash" + exit 1 +fi +# --- end runfiles.bash initialization --- + +source "$(rlocation "io_bazel/src/test/shell/integration_test_setup.sh")" \ + || { echo "integration_test_setup.sh not found!" >&2; exit 1; } + +case "$(uname -s | tr [:upper:] [:lower:])" in +msys*|mingw*|cygwin*) + declare -r is_windows=true + ;; +*) + declare -r is_windows=false + ;; +esac + +if "$is_windows"; then + export MSYS_NO_PATHCONV=1 + export MSYS2_ARG_CONV_EXCL="*" +fi + +JAVA_TOOLS_ZIP="$1"; shift +JAVA_TOOLS_PREBUILT_ZIP="$1"; shift + +echo "JAVA_TOOLS_ZIP=$JAVA_TOOLS_ZIP" + + +JAVA_TOOLS_RLOCATION=$(rlocation io_bazel/$JAVA_TOOLS_ZIP) + +if "$is_windows"; then + JAVA_TOOLS_ZIP_FILE_URL="file:///${JAVA_TOOLS_RLOCATION}" + JAVA_TOOLS_PREBUILT_ZIP_FILE_URL="file:///$(rlocation io_bazel/$JAVA_TOOLS_PREBUILT_ZIP)" +else + JAVA_TOOLS_ZIP_FILE_URL="file://${JAVA_TOOLS_RLOCATION}" + JAVA_TOOLS_PREBUILT_ZIP_FILE_URL="file://$(rlocation io_bazel/$JAVA_TOOLS_PREBUILT_ZIP)" +fi +JAVA_TOOLS_ZIP_FILE_URL=${JAVA_TOOLS_ZIP_FILE_URL:-} +JAVA_TOOLS_PREBUILT_ZIP_FILE_URL=${JAVA_TOOLS_PREBUILT_ZIP_FILE_URL:-} + + +function set_up() { + cat >>WORKSPACE <> WORKSPACE +} + +# Java source files version shall match --java_language_version_flag version. +function test_java17_text_block() { + mkdir -p java/main + cat >java/main/BUILD <java/main/Javac17Example.java <"${TEST_log}" \ + && fail "Running with --java_language_version=14 unexpectedly succeeded." + + bazel run java/main:Javac17Example --java_language_version=16 --java_runtime_version=16 \ + --test_output=all --verbose_failures &>"${TEST_log}" \ + && fail "Running with --java_language_version=16 unexpectedly succeeded." + + bazel run java/main:Javac17Example --java_language_version=11 --java_runtime_version=11 \ + --test_output=all --verbose_failures &>"${TEST_log}" \ + && fail "Running with --java_language_version=11 unexpectedly succeeded." + + bazel run java/main:Javac17Example --java_language_version=17 --java_runtime_version=17 \ + --test_output=all --verbose_failures &>"${TEST_log}" \ + || fail "Running with --java_language_version=17 failed" + expect_log "^Hello,\$" + expect_log "^World\$" +} + + +run_suite "Tests Java 17 language features" diff --git a/src/test/shell/bazel/testdata/jdk_http_archives.tmpl b/src/test/shell/bazel/testdata/jdk_http_archives.tmpl index aba09a6877a053..22be7fc2b68a91 100644 --- a/src/test/shell/bazel/testdata/jdk_http_archives.tmpl +++ b/src/test/shell/bazel/testdata/jdk_http_archives.tmpl @@ -165,3 +165,68 @@ exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) "https://cdn.azul.com/zulu/bin/zulu16.28.11-ca-jdk16.0.0-win_x64.zip", ], ) + +#################################### JDK 17 #################################### +# This must be kept in sync with the top-level WORKSPACE file. +http_archive( + name = "openjdk17_linux_archive", + build_file_content = """ +java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public']) +exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) +""", + sha256 = "37c4f8e48536cceae8c6c20250d6c385e176972532fd35759fa7d6015c965f56", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-linux_x64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-linux_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-linux_x64.tar.gz", + ], +) + +# This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives. +http_archive( + name = "openjdk17_darwin_archive", + build_file_content = """ +java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public']) +exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) +""", + sha256 = "6029b1fe6853cecad22ab99ac0b3bb4fb8c903dd2edefa91c3abc89755bbd47d", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-macosx_x64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_x64.tar.gz", + ], +) + +# This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives. +http_archive( + name = "openjdk17_darwin_aarch64_archive", + build_file_content = """ +java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public']) +exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) +""", + sha256 = "6b17f01f767ee7abf4704149ca4d86423aab9b16b68697b7d36e9b616846a8b0", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-macosx_aarch64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-macosx_aarch64.tar.gz", + ], +) + +# This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives. +http_archive( + name = "openjdk17_windows_archive", + build_file_content = """ +java_runtime(name = 'runtime', srcs = glob(['**']), visibility = ['//visibility:public']) +exports_files(["WORKSPACE"], visibility = ["//visibility:public"]) +""", + sha256 = "f4437011239f3f0031c794bb91c02a6350bc941d4196bdd19c9f157b491815a3", + strip_prefix = "zulu17.28.13-ca-jdk17.0.0-win_x64", + urls = [ + # TODO(cushon): uncomment once https://github.com/bazelbuild/bazel/issues/13965#issuecomment-927216970 is done + # "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-win_x64.zip", + "https://cdn.azul.com/zulu/bin/zulu17.28.13-ca-jdk17.0.0-win_x64.zip", + ], +) diff --git a/src/test/shell/testenv.sh.tmpl b/src/test/shell/testenv.sh.tmpl index 33becf39db9891..184229d8528098 100755 --- a/src/test/shell/testenv.sh.tmpl +++ b/src/test/shell/testenv.sh.tmpl @@ -297,6 +297,10 @@ EOF "openjdk16_darwin_aarch64_archive" "openjdk16_linux_archive" "openjdk16_windows_archive" + "openjdk17_darwin_archive" + "openjdk17_darwin_aarch64_archive" + "openjdk17_linux_archive" + "openjdk17_windows_archive" "openjdk_linux_aarch64_minimal" "openjdk_linux_minimal" "openjdk_macos_x86_64_minimal" @@ -326,6 +330,10 @@ EOF "remotejdk16_macos_for_testing" "remotejdk16_macos_aarch64_for_testing" "remotejdk16_win_for_testing" + "remotejdk17_linux_for_testing" + "remotejdk17_macos_for_testing" + "remotejdk17_macos_aarch64_for_testing" + "remotejdk17_win_for_testing" "rules_cc" "rules_java" "rules_proto" diff --git a/src/upload_all_java_tools.sh b/src/upload_all_java_tools.sh index 5fdb105ca850b3..0da2991b64970f 100755 --- a/src/upload_all_java_tools.sh +++ b/src/upload_all_java_tools.sh @@ -73,7 +73,7 @@ fi # Skip for now, as the test is broken on Windows. # See https://github.com/bazelbuild/bazel/issues/12244 for details if [[ "$platform" != "windows" ]]; then - for java_version in 11 15 16; do + for java_version in 11 15 16 17; do bazel test --verbose_failures --test_output=all --nocache_test_results \ //src/test/shell/bazel:bazel_java_test_local_java_tools_jdk${java_version} \ --define=LOCAL_JAVA_TOOLS_ZIP_URL="${file_url}" \ diff --git a/tools/jdk/BUILD.tools b/tools/jdk/BUILD.tools index f2e5edffdde5d2..ecddfe0c3e1bed 100644 --- a/tools/jdk/BUILD.tools +++ b/tools/jdk/BUILD.tools @@ -387,6 +387,15 @@ default_java_toolchain( target_version = "16", ) +# A toolchain that targets java 17. +default_java_toolchain( + name = "toolchain_jdk_17", + configuration = dict(), + java_runtime = "@bazel_tools//tools/jdk:remotejdk_17", + source_version = "17", + target_version = "17", +) + # Deprecated, do not use. # It will be removed after migration to Java toolchain resolution. default_java_toolchain( @@ -446,6 +455,10 @@ _JDKS = [ "remotejdk16_macos_aarch64", "remotejdk16_win", "remotejdk16_linux", + "remotejdk17_macos", + "remotejdk17_macos_aarch64", + "remotejdk17_win", + "remotejdk17_linux", ] [ @@ -476,6 +489,12 @@ java_runtime_version_alias( visibility = ["//visibility:public"], ) +java_runtime_version_alias( + name = "remotejdk_17", + runtime_version = "remotejdk_17", + visibility = ["//visibility:public"], +) + java_runtime_version_alias( name = "jdk_8", runtime_version = "8",