]> source.dussan.org Git - jgit.git/commitdiff
Bazel: Switch to using toolchain resolution for java rules 32/189132/9
authorDavid Ostrovsky <david@ostrovsky.org>
Fri, 24 Dec 2021 06:43:48 +0000 (07:43 +0100)
committerDavid Ostrovsky <d.ostrovsky@gmx.de>
Thu, 20 Jan 2022 10:40:51 +0000 (06:40 -0400)
Bump Bazel version to release 5.0.0. In this new Bazel release,
--incompatible_use_toolchain_resolution_for_java_rules is flipped, that
means that the build must be adapted to toolchain resolution.

Specification toolchain resolution for java rules is here: [1]. Main
tracking Bazel issue is here: [2].

Given that new Bazel release also added support for remote JDK 17, add
experimental support for building with remote JDK 17 to produce major
byte code version 61.

Test Plan:

To build with remote JDK 11 run:

  $ bazel build :all

To build with remote JDK 17 run:

  $ bazel build --config java17 :all

[1] https://docs.google.com/document/d/1MVbBxbKVKRJJY7DnkptHpvz7ROhyAYy4a-TZ-n7Q0r4/edit?usp=sharing
[2] https://github.com/bazelbuild/bazel/issues/7849

Change-Id: I8d26dff722c6677ea7642913b61e416b23ea9041

.bazelrc
.bazelversion
WORKSPACE
tools/BUILD

index e24be88639b36c35511be54605f47121881dc1a2..7626e5b4723b7d36cda4a730d6ca8de256fe61ce 100644 (file)
--- a/.bazelrc
+++ b/.bazelrc
@@ -3,7 +3,18 @@ build --repository_cache=~/.gerritcodereview/bazel-cache/repository
 build --experimental_strict_action_env
 build --action_env=PATH
 build --disk_cache=~/.gerritcodereview/bazel-cache/cas
-build --java_toolchain //tools:error_prone_warnings_toolchain
+
+# Builds using remote_jdk11, executes using remote_jdk11 or local_jdk
+build --java_language_version=11
+build --java_runtime_version=remotejdk_11
+build --tool_java_language_version=11
+build --tool_java_runtime_version=remotejdk_11
+
+# Builds using remote_jdk17, executes using remote_jdk11 or local_jdk
+build:java17 --java_language_version=17
+build:java17 --java_runtime_version=remotejdk_17
+build:java17 --tool_java_language_version=17
+build:java17 --tool_java_runtime_version=remotejdk_17
 
 test --build_tests_only
 test --test_output=errors
index fcdb2e109f68cff5600955a73908885fe8599bb4..0062ac971805f7b700058db4bb0f5c5b771dda76 100644 (file)
@@ -1 +1 @@
-4.0.0
+5.0.0
index 83838b70173f9b943da46e26806b16e77819257b..1d0aaceeb8063b0232d5859cc6f073dc45a114ed 100644 (file)
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,7 +1,6 @@
 workspace(name = "jgit")
 
 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
 load("//tools:bazlets.bzl", "load_bazlets")
 
 load_bazlets(commit = "f30a992da9fc855dce819875afb59f9dd6f860cd")
@@ -11,6 +10,10 @@ load(
     "maven_jar",
 )
 
+register_toolchains("//tools:error_prone_warnings_toolchain_java11_definition")
+
+register_toolchains("//tools:error_prone_warnings_toolchain_java17_definition")
+
 JMH_VERS = "1.32"
 
 maven_jar(
index b80b2bb3ab99d83934155305029a6d3519213d61..a10901982fec0d8a7954c427ba26001513830d13 100644 (file)
@@ -5,7 +5,7 @@ load(
 load("@rules_java//java:defs.bzl", "java_package_configuration")
 
 default_java_toolchain(
-    name = "error_prone_warnings_toolchain",
+    name = "error_prone_warnings_toolchain_java11",
     package_configuration = [
         ":error_prone",
     ],
@@ -14,6 +14,18 @@ default_java_toolchain(
     visibility = ["//visibility:public"],
 )
 
+default_java_toolchain(
+    name = "error_prone_warnings_toolchain_java17",
+    configuration = dict(),
+    java_runtime = "@bazel_tools//tools/jdk:remotejdk_17",
+    package_configuration = [
+        ":error_prone",
+    ],
+    source_version = "17",
+    target_version = "17",
+    visibility = ["//visibility:public"],
+)
+
 # Error Prone errors enabled by default; see ../.bazelrc for how this is
 # enabled. This warnings list is originally based on:
 # https://github.com/bazelbuild/BUILD_file_generator/blob/master/tools/bazel_defs/java.bzl