diff --git a/WORKSPACE b/WORKSPACE index 0ab394dc64e9cd..40922d56ea3fea 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -578,15 +578,15 @@ load("//scripts/docs:doc_versions.bzl", "DOC_VERSIONS") # Load shared base CSS theme from bazelbuild/bazel-website http_archive( name = "bazel_website", - urls = ["https://github.com/bazelbuild/bazel-website/archive/c174fa288aa079b68416d2ce2cc97268fa172f42.tar.gz"], - strip_prefix = "bazel-website-c174fa288aa079b68416d2ce2cc97268fa172f42", - sha256 = "a5f531dd1d62e6947dcfc279656ffc2fdf6f447c163914c5eabf7961b4cb6eb4", # TODO(https://github.com/bazelbuild/bazel/issues/10793) # - Export files from bazel-website's BUILD, instead of doing it here. # - Share more common stylesheets, like footer and navbar. build_file_content = """ exports_files(["_sass/style.scss"]) -""" +""", + sha256 = "a5f531dd1d62e6947dcfc279656ffc2fdf6f447c163914c5eabf7961b4cb6eb4", + strip_prefix = "bazel-website-c174fa288aa079b68416d2ce2cc97268fa172f42", + urls = ["https://github.com/bazelbuild/bazel-website/archive/c174fa288aa079b68416d2ce2cc97268fa172f42.tar.gz"], ) # Skydoc recommends declaring its dependencies via "*_dependencies" functions. @@ -715,6 +715,17 @@ 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 = "remote_java_tools_beta_linux_for_testing", + patch_cmds = EXPORT_WORKSPACE_IN_BUILD_FILE, + patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_FILE_WIN, + sha256 = "74d30ccf161c58bb69db9b2171c954a0563b2d1ff6f5831debbe71ced105c388", + urls = [ + "https://github.com/davido/java_tools/releases/download/javac11-v11.0/java_tools_javac11_linux-v11.0.zip", + ], +) + # This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE. http_archive( name = "remote_java_tools_windows_for_testing", @@ -727,6 +738,18 @@ 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 = "remote_java_tools_windows_beta_for_testing", + patch_cmds = EXPORT_WORKSPACE_IN_BUILD_FILE, + patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_FILE_WIN, + sha256 = "444c391977e50af4e10549a28d021069d2ca7745a0e7b9b968a7b153fe3ea430", + urls = [ + "https://mirror.bazel.build/bazel_java_tools/releases/javac11/v8.0/java_tools_javac11_windows-v8.0.zip", + "https://github.com/bazelbuild/java_tools/releases/download/javac11_v8.0/java_tools_javac11_windows-v8.0.zip", + ], +) + # This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE. http_archive( name = "remote_java_tools_darwin_for_testing", @@ -739,6 +762,17 @@ 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 = "remote_java_tools_darwin_beta_for_testing", + patch_cmds = EXPORT_WORKSPACE_IN_BUILD_FILE, + patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_FILE_WIN, + sha256 = "252520f0cd5dd7e9b18062dc731f8ae248993650f12a9b613fcd9ebda591d242", + urls = [ + "https://github.com/davido/java_tools/releases/download/javac11-v11.0/java_tools_javac11_darwin-v11.0.zip", + ], +) + # This must be kept in sync with src/test/shell/bazel/testdata/jdk_http_archives. http_archive( name = "remote_java_tools_javac11_test_linux", @@ -921,4 +955,5 @@ register_local_rc_exe_toolchains() register_toolchains("//src/main/res:empty_rc_toolchain") load("//tools/distributions/debian:deps.bzl", "debian_deps") + debian_deps() diff --git a/src/BUILD b/src/BUILD index 0d46818463b214..6b53e7236b229b 100644 --- a/src/BUILD +++ b/src/BUILD @@ -747,6 +747,7 @@ filegroup( "@openjdk_macos_minimal//file", "@openjdk_win_minimal//file", "@remote_coverage_tools_for_testing//:WORKSPACE", + "@remote_java_tools_darwin_beta_for_testing//:WORKSPACE", "@remote_java_tools_darwin_for_testing//:WORKSPACE", "@remote_java_tools_javac11_test_darwin//:WORKSPACE", "@remote_java_tools_javac11_test_linux//:WORKSPACE", @@ -754,7 +755,9 @@ filegroup( "@remote_java_tools_javac12_test_darwin//:WORKSPACE", "@remote_java_tools_javac12_test_linux//:WORKSPACE", "@remote_java_tools_javac12_test_windows//:WORKSPACE", + "@remote_java_tools_linux_beta_for_testing//:WORKSPACE", "@remote_java_tools_linux_for_testing//:WORKSPACE", + "@remote_java_tools_windows_beta_for_testing//:WORKSPACE", "@remote_java_tools_windows_for_testing//:WORKSPACE", "@remotejdk11_linux_aarch64_for_testing//:WORKSPACE", "@remotejdk11_linux_for_testing//:WORKSPACE", diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE index 95f7f0b797803e..65755a22b17e0f 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE @@ -152,6 +152,15 @@ maybe( ], ) +maybe( + http_archive, + name = "remote_java_tools_linux_beta", + sha256 = "74d30ccf161c58bb69db9b2171c954a0563b2d1ff6f5831debbe71ced105c388", + urls = [ + "https://github.com/davido/java_tools/releases/download/javac11-v11.0/java_tools_javac11_linux-v11.0.zip", + ], +) + # This must be kept in sync with the top-level WORKSPACE file. maybe( http_archive, @@ -163,6 +172,17 @@ maybe( ], ) +# TODO(davido): Build java_tools beta release on "other" platform +maybe( + http_archive, + name = "remote_java_tools_windows_beta", + sha256 = "444c391977e50af4e10549a28d021069d2ca7745a0e7b9b968a7b153fe3ea430", + urls = [ + "https://mirror.bazel.build/bazel_java_tools/releases/javac11/v8.0/java_tools_javac11_windows-v8.0.zip", + "https://github.com/bazelbuild/java_tools/releases/download/javac11_v8.0/java_tools_javac11_windows-v8.0.zip", + ], +) + # This must be kept in sync with the top-level WORKSPACE file. maybe( http_archive, @@ -174,6 +194,15 @@ maybe( ], ) +maybe( + http_archive, + name = "remote_java_tools_darwin_beta", + sha256 = "252520f0cd5dd7e9b18062dc731f8ae248993650f12a9b613fcd9ebda591d242", + urls = [ + "https://github.com/davido/java_tools/releases/download/javac11-v11.0/java_tools_javac11_darwin-v11.0.zip", + ], +) + maybe( http_archive, "rules_java", diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaConfiguration.java index 022fd64cd05e7e..d5bfee00fa4bcb 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaConfiguration.java @@ -39,7 +39,6 @@ /** A java compiler configuration containing the flags required for compilation. */ @Immutable public final class JavaConfiguration extends Fragment implements JavaConfigurationApi { - /** Values for the --java_classpath option */ public enum JavaClasspathMode { /** Use full transitive classpaths, the default behavior. */ @@ -213,6 +212,11 @@ public enum ImportDepsCheckingLevel { javaOptions.hostJavaToolchain)); } } + if (javaOptions.useJavaToolsBetaRelease) { + // TODO(davido): Add some checks, that mutual exclusive options are not allowed. + javaOptions.javaToolchain = + javaOptions.hostJavaToolchain = javaOptions.defaultJavaToolchainBeta(); + } } @Override @@ -371,7 +375,6 @@ public boolean useLegacyBazelJavaTest() { return useLegacyBazelJavaTest; } - /** * Make it mandatory for java_test targets to explicitly declare any JUnit or Hamcrest * dependencies instead of accidentally obtaining them from the TestRunner's dependencies. diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java index 29aec10a1d3fe1..132d665707cb4e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java @@ -86,6 +86,8 @@ public ImportDepsCheckingLevelConverter() { public Label javaBase; private static final String DEFAULT_JAVA_TOOLCHAIN = "@bazel_tools//tools/jdk:remote_toolchain"; + private static final String DEFAULT_JAVA_TOOLCHAIN_BETA = + "@bazel_tools//tools/jdk:remote_toolchain_beta"; @Option( name = "java_toolchain", @@ -580,6 +582,18 @@ public ImportDepsCheckingLevelConverter() { "Disables the resource_jars attribute; use java_import and deps or runtime_deps instead.") public boolean disallowResourceJars; + @Option( + name = "incompatible_use_java_tools_beta_release", + defaultValue = "false", + documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, + effectTags = {OptionEffectTag.UNKNOWN}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, + help = "Activates java_tools beta release.") + public boolean useJavaToolsBetaRelease; + @Option( name = "incompatible_load_java_rules_from_bzl", defaultValue = "false", @@ -629,6 +643,10 @@ Label defaultJavaToolchain() { return Label.parseAbsoluteUnchecked(DEFAULT_JAVA_TOOLCHAIN); } + Label defaultJavaToolchainBeta() { + return Label.parseAbsoluteUnchecked(DEFAULT_JAVA_TOOLCHAIN_BETA); + } + @Override public FragmentOptions getHost() { JavaOptions host = (JavaOptions) getDefault(); @@ -679,5 +697,4 @@ public FragmentOptions getHost() { return host; } - } diff --git a/src/test/py/bazel/test_base.py b/src/test/py/bazel/test_base.py index 8f92c52b38e334..907a39d49af4fc 100644 --- a/src/test/py/bazel/test_base.py +++ b/src/test/py/bazel/test_base.py @@ -61,8 +61,11 @@ class TestBase(unittest.TestCase): 'remotejdk11_macos_for_testing', 'remotejdk11_win_for_testing', 'remote_java_tools_darwin_for_testing', + 'remote_java_tools_darwin_beta_for_testing', 'remote_java_tools_linux_for_testing', + 'remote_java_tools_linux_beta_for_testing', 'remote_java_tools_windows_for_testing', + 'remote_java_tools_windows_beta_for_testing', 'remote_coverage_tools_for_testing', ) diff --git a/src/test/shell/testenv.sh b/src/test/shell/testenv.sh index cd447779bd4f26..bc33db5a3930ff 100755 --- a/src/test/shell/testenv.sh +++ b/src/test/shell/testenv.sh @@ -299,6 +299,7 @@ EOF "openjdk_win_minimal" "remote_coverage_tools_for_testing" "remote_java_tools_darwin_for_testing" + "remote_java_tools_darwin_beta_for_testing" "remote_java_tools_javac11_test_darwin" "remote_java_tools_javac11_test_linux" "remote_java_tools_javac11_test_windows" @@ -306,7 +307,9 @@ EOF "remote_java_tools_javac12_test_linux" "remote_java_tools_javac12_test_windows" "remote_java_tools_linux_for_testing" + "remote_java_tools_linux_beta_for_testing" "remote_java_tools_windows_for_testing" + "remote_java_tools_windows_beta_for_testing" "remotejdk11_linux_for_testing" "remotejdk11_linux_aarch64_for_testing" "remotejdk11_macos_for_testing" diff --git a/tools/jdk/BUILD b/tools/jdk/BUILD index cbcff60be3e0de..0c7eddb3179396 100644 --- a/tools/jdk/BUILD +++ b/tools/jdk/BUILD @@ -387,6 +387,17 @@ alias( }), ) +alias( + name = "remote_toolchain_beta", + actual = select({ + "//src/conditions:darwin": "@remote_java_tools_darwin_beta//:toolchain", + "//src/conditions:darwin_x86_64": "@remote_java_tools_darwin_beta//:toolchain", + "//src/conditions:windows": "@remote_java_tools_windows_beta//:toolchain", + "//src/conditions:linux_x86_64": "@remote_java_tools_linux_beta//:toolchain", + "//conditions:default": "@bazel_tools//tools/jdk:legacy_toolchain", + }), +) + # The 'vanilla' toolchain is an unsupported alternative to the default. # # It does not provider any of the following features: