Bazel: Add support for toolchain_java11
This change also removes the support for building with Java 9 and 10. Test Plan: * Run the tests with Java 8 toolchain (the same as before this change): $ bazel test //... * Run the tests with remote Java 11 toolchain (new feature added here): $ bazel test --host_javabase=@bazel_tools//tools/jdk:remote_jdk11 \ --javabase=@bazel_tools//tools/jdk:remote_jdk11 \ --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java11 \ --java_toolchain=@bazel_tools//tools/jdk:toolchain_java11 \ //... Change-Id: Ib67dcc50a43f998bc8f5a363a8f681e3693d1f26
This commit is contained in:
parent
3021ced2e6
commit
cf4f70bc2a
4
BUILD
4
BUILD
@ -4,9 +4,9 @@ load("//tools/bzl:pkg_war.bzl", "pkg_war")
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
config_setting(
|
||||
name = "java9",
|
||||
name = "java11",
|
||||
values = {
|
||||
"java_toolchain": "@bazel_tools//tools/jdk:toolchain_java9",
|
||||
"java_toolchain": "@bazel_tools//tools/jdk:toolchain_java11",
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -31,17 +31,17 @@ To check the installed version of Java, open a terminal window and run:
|
||||
|
||||
`java -version`
|
||||
|
||||
[[java-10]]
|
||||
==== Java 10 support
|
||||
[[java-12]]
|
||||
==== Java 12 support
|
||||
|
||||
Java 10 (and newer) is supported through vanilla java toolchain
|
||||
Java 12 (and newer) is supported through vanilla java toolchain
|
||||
link:https://docs.bazel.build/versions/master/toolchains.html[Bazel option].
|
||||
To build Gerrit with Java 10 and newer, specify vanilla java toolchain and
|
||||
To build Gerrit with Java 12 and newer, specify vanilla java toolchain and
|
||||
provide the path to JDK home:
|
||||
|
||||
```
|
||||
$ bazel build \
|
||||
--define=ABSOLUTE_JAVABASE=<path-to-java-10> \
|
||||
--define=ABSOLUTE_JAVABASE=<path-to-java-12> \
|
||||
--host_javabase=@bazel_tools//tools/jdk:absolute_javabase \
|
||||
--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \
|
||||
--java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \
|
||||
@ -53,7 +53,7 @@ bazel test runs the test using the target javabase:
|
||||
|
||||
```
|
||||
$ bazel test \
|
||||
--define=ABSOLUTE_JAVABASE=<path-to-java-10> \
|
||||
--define=ABSOLUTE_JAVABASE=<path-to-java-12> \
|
||||
--javabase=@bazel_tools//tools/jdk:absolute_javabase \
|
||||
--host_javabase=@bazel_tools//tools/jdk:absolute_javabase \
|
||||
--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \
|
||||
@ -66,7 +66,7 @@ they could be added to ~/.bazelrc resource file:
|
||||
|
||||
```
|
||||
$ cat << EOF > ~/.bazelrc
|
||||
> build --define=ABSOLUTE_JAVABASE=<path-to-java-10>
|
||||
> build --define=ABSOLUTE_JAVABASE=<path-to-java-12>
|
||||
> build --javabase=@bazel_tools//tools/jdk:absolute_javabase
|
||||
> build --host_javabase=@bazel_tools//tools/jdk:absolute_javabase
|
||||
> build --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla
|
||||
@ -78,30 +78,31 @@ Now, invoking Bazel with just `bazel build :release` would include
|
||||
all those options.
|
||||
|
||||
Note that the follow option must be added to `container.javaOptions`
|
||||
in `$gerrit_site/etc/gerrit.config` to run Gerrit with Java 10|11|...:
|
||||
in `$gerrit_site/etc/gerrit.config` to run Gerrit with Java 12:
|
||||
|
||||
```
|
||||
[container]
|
||||
javaOptions = --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
|
||||
```
|
||||
|
||||
[[java-9]]
|
||||
==== Java 9 support
|
||||
[[java-11]]
|
||||
==== Java 11 support
|
||||
|
||||
Java 9 is supported through alternative java toolchain
|
||||
Java 11 is supported through alternative java toolchain
|
||||
link:https://docs.bazel.build/versions/master/toolchains.html[Bazel option].
|
||||
The Java 9 support is backwards compatible. Java 8 is still the default.
|
||||
To build Gerrit with Java 9, specify JDK 9 java toolchain:
|
||||
To build Gerrit with Java 11, specify JDK 11 java toolchain:
|
||||
|
||||
```
|
||||
$ bazel build \
|
||||
--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java9 \
|
||||
--java_toolchain=@bazel_tools//tools/jdk:toolchain_java9 \
|
||||
--host_javabase=@bazel_tools//tools/jdk:remote_jdk11 \
|
||||
--javabase=@bazel_tools//tools/jdk:remote_jdk11 \
|
||||
--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java11 \
|
||||
--java_toolchain=@bazel_tools//tools/jdk:toolchain_java11 \
|
||||
:release
|
||||
```
|
||||
|
||||
Note that the follow option must be added to `container.javaOptions`
|
||||
in `$gerrit_site/etc/gerrit.config` to run Gerrit with Java 9:
|
||||
in `$gerrit_site/etc/gerrit.config` to run Gerrit with Java 11:
|
||||
|
||||
```
|
||||
[container]
|
||||
|
@ -17,7 +17,7 @@ java_library(
|
||||
data = ["//lib:LICENSE-Apache2.0"],
|
||||
exports = ["@greenmail//jar"],
|
||||
runtime_deps = select({
|
||||
"//:java9": POST_JDK8_DEPS,
|
||||
"//:java11": POST_JDK8_DEPS,
|
||||
"//:java_next": POST_JDK8_DEPS,
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
|
@ -7,7 +7,7 @@ DUMMY = ["dummy.sh"]
|
||||
sh_test(
|
||||
name = "test_examples",
|
||||
srcs = select({
|
||||
"//:java9": DUMMY,
|
||||
"//:java11": DUMMY,
|
||||
"//:java_next": DUMMY,
|
||||
"//conditions:default": ["run.sh"],
|
||||
}),
|
||||
|
@ -80,7 +80,7 @@ _java_doc = rule(
|
||||
def java_doc(**kwargs):
|
||||
libs = kwargs.get("libs", [])
|
||||
libs = libs + select({
|
||||
"//:java9": [],
|
||||
"//:java11": [],
|
||||
"//:java_next": [],
|
||||
# TODO(davido): Remove this dependency, when Java 8 support is removed.
|
||||
# auto-value generates @javax.annotation.Generated annotation on generated
|
||||
|
@ -82,7 +82,7 @@ def junit_tests(name, srcs, **kwargs):
|
||||
)
|
||||
jvm_flags = kwargs.get("jvm_flags", [])
|
||||
jvm_flags = jvm_flags + select({
|
||||
"//:java9": POST_JDK8_OPTS,
|
||||
"//:java11": POST_JDK8_OPTS,
|
||||
"//:java_next": POST_JDK8_OPTS,
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user