gerrit/BUILD
David Ostrovsky 7e1fcd9d44 Bazel: Consume toolchain_java from @bazel_tools//tools/jdk package
Starting from Bazel 0.19.x toolchain_java and absolute_javabase are
exposed in Bazel's @bazel_tools//tools/jdk package. Remove our own
definition of those rules and adapt the documentation.

Test Plan:

To build with Java 11 and newer Java versions:

* To build:

  $ bazel build \
    --define=ABSOLUTE_JAVABASE=/usr/lib64/jvm/java-11 \
    --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 \
    :release

* To run the tests --javabase option must be passed as well:

  $ bazel test \
    --define=ABSOLUTE_JAVABASE=/usr/lib64/jvm/java-11 \
    --javabase=@bazel_tools//tools/jdk:absolute_javabase \
    --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 \
    //...

Alternatively, JAVA_HOME should be set to the new Java version:

  $ JAVA_HOME=/usr/lib64/jvm/java-11 bazel test \
    --define=ABSOLUTE_JAVABASE=/usr/lib64/jvm/java-11 \
    --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 \
    //...

Change-Id: I7fc4499fcd52f5b0d95ffcb177b89767000b43ce
2018-11-12 12:07:29 -08:00

90 lines
2.0 KiB
Python

package(default_visibility = ["//visibility:public"])
load("//tools/bzl:genrule2.bzl", "genrule2")
load("//tools/bzl:pkg_war.bzl", "pkg_war")
config_setting(
name = "java9",
values = {
"java_toolchain": "@bazel_tools//tools/jdk:toolchain_java9",
},
)
config_setting(
name = "java_next",
values = {
"java_toolchain": "@bazel_tools//tools/jdk:toolchain_vanilla",
},
)
genrule(
name = "gen_version",
outs = ["version.txt"],
cmd = ("cat bazel-out/volatile-status.txt bazel-out/stable-status.txt | " +
"grep STABLE_BUILD_GERRIT_LABEL | cut -d ' ' -f 2 > $@"),
stamp = 1,
visibility = ["//visibility:public"],
)
genrule(
name = "LICENSES",
srcs = ["//Documentation:licenses.txt"],
outs = ["LICENSES.txt"],
cmd = "cp $< $@",
visibility = ["//visibility:public"],
)
pkg_war(
name = "gerrit",
ui = "polygerrit",
)
pkg_war(
name = "headless",
ui = None,
)
pkg_war(
name = "polygerrit",
ui = "polygerrit",
)
pkg_war(
name = "release",
context = ["//plugins:core"],
doc = True,
ui = "ui_optdbg_r",
)
pkg_war(
name = "withdocs",
doc = True,
)
API_DEPS = [
"//java/com/google/gerrit/acceptance:framework_deploy.jar",
"//java/com/google/gerrit/acceptance:libframework-lib-src.jar",
"//java/com/google/gerrit/acceptance:framework-javadoc",
"//java/com/google/gerrit/extensions:extension-api_deploy.jar",
"//java/com/google/gerrit/extensions:libapi-src.jar",
"//java/com/google/gerrit/extensions:extension-api-javadoc",
"//plugins:plugin-api_deploy.jar",
"//plugins:plugin-api-sources_deploy.jar",
"//plugins:plugin-api-javadoc",
"//gerrit-plugin-gwtui:gwtui-api_deploy.jar",
"//gerrit-plugin-gwtui:gwtui-api-source_deploy.jar",
"//gerrit-plugin-gwtui:gwtui-api-javadoc",
]
genrule2(
name = "api",
testonly = 1,
srcs = API_DEPS,
outs = ["api.zip"],
cmd = " && ".join([
"cp $(SRCS) $$TMP",
"cd $$TMP",
"zip -qr $$ROOT/$@ .",
]),
)