From 2f23187b8db361448b98a65e4821df1f3d41d8eb Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Tue, 11 Jan 2022 21:51:15 +0100 Subject: Bazel: Use Java 8 per default to guarantee source level compatibility At the time the change 264535 was submitted, that switched Java default to Java 11, not all Gerrit users were ready to abandon Java 8 compatibility. To provide Java 8 compatibility it was decided to perform CI verification with Java 8, by overriding the java toolchain option on GerritForge CI (core build) and Zuul (plugins build). Today the situation is different. Starting from stable-3.5 branch Java 8 compatibility has been dropped. Still we guarantee the Java 8 compatibility on stable-3.3 and stable-3.4 branches. To achieve this, the java toolchain option is overridden on stable-3.3 and stable-3.4 branches on the CI. To simplify the build toolchain and the CI configurations, we would like to rely only on the default java toolchain (provided in .bazelrc) to be the minimum guaranteed compatible Java version (on each branch). That way the default bazel invocation: $ bazel build :release would always provide the desired result per default. This change should be reverted when merged up to stable-3.5 branch. To summarize: before this change is submitted, the situation is: stable-3.3: default toolchain: Java 11, guaranteed compatibility: Java 8 stable-3.4: default toolchain: Java 11, guaranteed compatibility: Java 8 from stable-3.5: default toolchain/guaranteed compatibility: Java 11 after this change is submitted, merged to stable-3.4 branch and reverted started from stable-3.5 branch, the situation is: stable-3.3: default toolchain/guaranteed compatibility: Java 8 stable-3.4: default toolchain/guaranteed compatibility: Java 8 from stable-3.5: default toolchain/guaranteed compatibility: Java 11 Change-Id: Ieb0d627ce5f4d2753fe637fb67123e6431796940 --- .bazelrc | 4 ++-- Documentation/dev-bazel.txt | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.bazelrc b/.bazelrc index 5b0fa814a6..72138d2db8 100644 --- a/.bazelrc +++ b/.bazelrc @@ -2,7 +2,7 @@ build --workspace_status_command="python3 ./tools/workspace_status.py" build --repository_cache=~/.gerritcodereview/bazel-cache/repository build --action_env=PATH build --disk_cache=~/.gerritcodereview/bazel-cache/cas -build --java_toolchain=//tools:error_prone_warnings_toolchain_java11 +build --java_toolchain=//tools:error_prone_warnings_toolchain # Enable strict_action_env flag to. For more information on this feature see # https://groups.google.com/forum/#!topic/bazel-discuss/_VmRfMyyHBk. @@ -13,6 +13,6 @@ build --incompatible_strict_action_env test --build_tests_only test --test_output=errors -test --java_toolchain=//tools:error_prone_warnings_toolchain_java11 +test --java_toolchain=//tools:error_prone_warnings_toolchain import %workspace%/tools/remote-bazelrc diff --git a/Documentation/dev-bazel.txt b/Documentation/dev-bazel.txt index bf45836dad..5d71b41093 100644 --- a/Documentation/dev-bazel.txt +++ b/Documentation/dev-bazel.txt @@ -55,17 +55,16 @@ Java 8 is a legacy Java release and support for Java 8 will be discontinued in future gerrit releases. To build Gerrit with Java 8 language level, run: ``` - $ bazel build --java_toolchain //tools:error_prone_warnings_toolchain :release + $ bazel build :release ``` [[java-11]] ==== Java 11 support -Java language level 11 is the default. To build Gerrit with Java 11 language -level, run: +To build Gerrit with Java 11 language level, run: ``` - $ bazel build :release + $ bazel build --java_toolchain=//tools:error_prone_warnings_toolchain_java11 :release ``` [[java-13]] -- cgit v1.2.3