blob: 00550315f4ec4500c592a9e4ef6120e94083376c [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
Carmelo Cascone87b893e2019-11-12 10:34:05 -08006load("//tools/build/bazel:variables.bzl", "DEFAULT_JAVA_VERSION")
Carmelo Cascone395b2312019-06-18 17:34:16 -07007load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain")
8
9default_java_toolchain(
10 name = "default_toolchain",
Carmelo Cascone87b893e2019-11-12 10:34:05 -080011 source_version = DEFAULT_JAVA_VERSION,
12 target_version = DEFAULT_JAVA_VERSION,
Carmelo Cascone395b2312019-06-18 17:34:16 -070013 visibility = ["//visibility:public"],
14)
15
16alias(
17 name = "default_jdk",
18 actual = "@bazel_tools//tools/jdk:remote_jdk11",
19 visibility = ["//visibility:public"],
20)
21
22# We use the following rule to package the same JDK used for building and make
23# it available for external scripts as their JAVA_HOME, such as for `bazel run
24# onos-local`.
25
26# FIXME: @bazel_tools//tools/jdk:current_java_runtime should be fixed upstream
27# to include the missing JDK conf/security files, required by Karaf. The
28# workaround for now is to check in those files here and include them in the
29# produced JDK tar.
30
31genrule(
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -070032 name = "current_jdk_tar",
Carmelo Cascone395b2312019-06-18 17:34:16 -070033 srcs = [
34 "@bazel_tools//tools/jdk:current_java_runtime",
35 ":conf-security",
36 ],
Carmelo Cascone3dcb7fd2019-06-26 14:08:36 -070037 outs = ["current_jdk.tar.gz"],
38 cmd = "mkdir current_jdk && " +
39 "cp -r $(JAVABASE)/* current_jdk/ && " +
40 "cp -r tools/build/jdk/* current_jdk/ && " +
41 "tar -hczf $(location current_jdk.tar.gz) current_jdk",
Carmelo Cascone395b2312019-06-18 17:34:16 -070042 output_to_bindir = True,
43 toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"],
44 visibility = ["//visibility:public"],
45)
46
47filegroup(
48 name = "conf-security",
49 srcs = glob(["conf/security/**"]),
50)