Merge "Bazel: Add support for Java 11 and newer Java versions"
This commit is contained in:
commit
f27ec617e1
2
BUILD
2
BUILD
@ -15,7 +15,7 @@ config_setting(
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "java10",
|
||||
name = "java_next",
|
||||
values = {
|
||||
"java_toolchain": ":toolchain_vanilla",
|
||||
},
|
||||
|
@ -6,7 +6,7 @@
|
||||
To build Gerrit from source, you need:
|
||||
|
||||
* A Linux or macOS system (Windows is not supported at this time)
|
||||
* A JDK for Java 8|9|10
|
||||
* A JDK for Java 8|9|10|11|...
|
||||
* Python 2 or 3
|
||||
* Node.js
|
||||
* link:https://www.bazel.io/versions/master/docs/install.html[Bazel]
|
||||
@ -14,11 +14,11 @@ To build Gerrit from source, you need:
|
||||
* zip, unzip
|
||||
* gcc
|
||||
|
||||
[[Java 10 support]]
|
||||
Java 10 is supported through vanilla java toolchain
|
||||
[[Java 10 and newer version support]]
|
||||
Java 10 (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, specify vanilla java toolchain and provide
|
||||
path to Java 10 home:
|
||||
To build Gerrit with Java 10 and newer, specify vanilla java toolchain and
|
||||
provide the path to JDK home:
|
||||
|
||||
```
|
||||
$ bazel build --host_javabase=:absolute_javabase \
|
||||
@ -29,12 +29,40 @@ path to Java 10 home:
|
||||
:release
|
||||
```
|
||||
|
||||
Note that the following options must be added to `container.javaOptions`
|
||||
in `$gerrit_site/etc/gerrit.config` to run Gerrit with Java 10:
|
||||
To run the tests, `--javabase` option must be passed as well, because
|
||||
bazel test runs the test using the target javabase:
|
||||
|
||||
```
|
||||
$ bazel test --host_javabase=:absolute_javabase \
|
||||
--javabase=:absolute_javabase \
|
||||
--define=ABSOLUTE_JAVABASE=<path-to-java-10> \
|
||||
--define=USE_ABSOLUTE_JAVABASE=true \
|
||||
--host_java_toolchain=//:toolchain_vanilla \
|
||||
--java_toolchain=//:toolchain_vanilla \
|
||||
//...
|
||||
```
|
||||
|
||||
To avoid passing all those options on every Bazel build invocation,
|
||||
they could be added to ~/.bazelrc resource file:
|
||||
|
||||
```
|
||||
$ cat << EOF > ~/.bazelrc
|
||||
> build --define=ABSOLUTE_JAVABASE=<path-to-java-10>
|
||||
> build --javabase=:absolute_javabase
|
||||
> build --host_javabase=:absolute_javabase
|
||||
> build --host_java_toolchain=//:toolchain_vanilla
|
||||
> build --java_toolchain=//:toolchain_vanilla
|
||||
> EOF
|
||||
```
|
||||
|
||||
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|...:
|
||||
|
||||
```
|
||||
[container]
|
||||
javaOptions = --add-modules java.activation
|
||||
javaOptions = --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
|
||||
```
|
||||
|
||||
@ -51,13 +79,12 @@ To build Gerrit with Java 9, specify JDK 9 java toolchain:
|
||||
:release
|
||||
```
|
||||
|
||||
Note that the following option must be added to `container.javaOptions`
|
||||
Note that the follow option must be added to `container.javaOptions`
|
||||
in `$gerrit_site/etc/gerrit.config` to run Gerrit with Java 9:
|
||||
|
||||
```
|
||||
[container]
|
||||
javaOptions = --add-modules java.activation \
|
||||
--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
|
||||
javaOptions = --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
|
||||
```
|
||||
|
||||
[[build]]
|
||||
|
@ -1127,6 +1127,12 @@ maven_jar(
|
||||
sha1 = "65bd0cacc9c79a21c6ed8e9f588577cd3c2f85b9",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "javax-activation",
|
||||
artifact = "javax.activation:activation:1.1.1",
|
||||
sha1 = "485de3a253e23f645037828c07f1d7f1af40763a",
|
||||
)
|
||||
|
||||
load("//tools/bzl:js.bzl", "bower_archive", "npm_binary")
|
||||
|
||||
# NPM binaries bundled along with their dependencies.
|
||||
|
@ -1,8 +1,23 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
POST_JDK8_DEPS = [":javax-activation"]
|
||||
|
||||
java_library(
|
||||
name = "javax-activation",
|
||||
testonly = 1,
|
||||
data = ["//lib:LICENSE-DO_NOT_DISTRIBUTE"],
|
||||
exports = ["@javax-activation//jar"],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "greenmail",
|
||||
testonly = 1,
|
||||
data = ["//lib:LICENSE-Apache2.0"],
|
||||
visibility = ["//visibility:public"],
|
||||
exports = ["@greenmail//jar"],
|
||||
runtime_deps = select({
|
||||
"//:java9": POST_JDK8_DEPS,
|
||||
"//:java_next": POST_JDK8_DEPS,
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)
|
||||
|
@ -68,7 +68,6 @@ POST_JDK8_OPTS = [
|
||||
# Enforce JDK 8 compatibility on Java 9, see
|
||||
# https://docs.oracle.com/javase/9/intl/internationalization-enhancements-jdk-9.htm#JSINT-GUID-AF5AECA7-07C1-4E7D-BC10-BC7E73DC6C7F
|
||||
"-Djava.locale.providers=COMPAT,CLDR,SPI",
|
||||
"--add-modules java.activation",
|
||||
"--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED",
|
||||
]
|
||||
|
||||
@ -82,7 +81,7 @@ def junit_tests(name, srcs, **kwargs):
|
||||
jvm_flags = kwargs.get("jvm_flags", [])
|
||||
jvm_flags = jvm_flags + select({
|
||||
"//:java9": POST_JDK8_OPTS,
|
||||
"//:java10": POST_JDK8_OPTS,
|
||||
"//:java_next": POST_JDK8_OPTS,
|
||||
"//conditions:default": [],
|
||||
})
|
||||
native.java_test(
|
||||
|
Loading…
Reference in New Issue
Block a user