blob: 59934fc638dd2a7306521dd46051c6bb36625bd1 [file] [log] [blame]
Carmelo Cascone395b2312019-06-18 17:34:16 -07001# This is where we define the JDK used to build ONOS, as well as the language
2# source and target values passed to javac. The :default_toolchain and
3# :default_jdk are expected to be passed as arguments when invoking bazel build
4# (see onos/.bazelrc)
5
6load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain")
7
8default_java_toolchain(
9 name = "default_toolchain",
10 source_version = "11",
11 target_version = "11",
12 visibility = ["//visibility:public"],
13)
14
15alias(
16 name = "default_jdk",
17 actual = "@bazel_tools//tools/jdk:remote_jdk11",
18 visibility = ["//visibility:public"],
19)
20
21# We use the following rule to package the same JDK used for building and make
22# it available for external scripts as their JAVA_HOME, such as for `bazel run
23# onos-local`.
24
25# FIXME: @bazel_tools//tools/jdk:current_java_runtime should be fixed upstream
26# to include the missing JDK conf/security files, required by Karaf. The
27# workaround for now is to check in those files here and include them in the
28# produced JDK tar.
29
30genrule(
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -070031 name = "current_jdk_tar",
Carmelo Cascone395b2312019-06-18 17:34:16 -070032 srcs = [
33 "@bazel_tools//tools/jdk:current_java_runtime",
34 ":conf-security",
35 ],
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -070036 outs = ["current_jdk.tar.gz"],
37 cmd = "mkdir current_jdk && " +
38 "cp -r $(JAVABASE)/* current_jdk/ && " +
39 "cp -r tools/build/jdk/* current_jdk/ && " +
40 "tar -hczf $(location current_jdk.tar.gz) current_jdk",
Carmelo Cascone395b2312019-06-18 17:34:16 -070041 output_to_bindir = True,
42 toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"],
43 visibility = ["//visibility:public"],
44)
45
46filegroup(
47 name = "conf-security",
48 srcs = glob(["conf/security/**"]),
49)