Carmelo Cascone | 395b231 | 2019-06-18 17:34:16 -0700 | [diff] [blame] | 1 | # 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 Cascone | 87b893e | 2019-11-12 10:34:05 -0800 | [diff] [blame] | 6 | load("//tools/build/bazel:variables.bzl", "DEFAULT_JAVA_VERSION") |
Carmelo Cascone | 395b231 | 2019-06-18 17:34:16 -0700 | [diff] [blame] | 7 | load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain") |
| 8 | |
| 9 | default_java_toolchain( |
| 10 | name = "default_toolchain", |
Carmelo Cascone | 87b893e | 2019-11-12 10:34:05 -0800 | [diff] [blame] | 11 | source_version = DEFAULT_JAVA_VERSION, |
| 12 | target_version = DEFAULT_JAVA_VERSION, |
Carmelo Cascone | 395b231 | 2019-06-18 17:34:16 -0700 | [diff] [blame] | 13 | visibility = ["//visibility:public"], |
| 14 | ) |
| 15 | |
| 16 | alias( |
| 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 | |
| 31 | genrule( |
Carmelo Cascone | 3dcb7fd | 2019-06-26 14:08:36 -0700 | [diff] [blame] | 32 | name = "current_jdk_tar", |
Carmelo Cascone | 395b231 | 2019-06-18 17:34:16 -0700 | [diff] [blame] | 33 | srcs = [ |
| 34 | "@bazel_tools//tools/jdk:current_java_runtime", |
| 35 | ":conf-security", |
| 36 | ], |
Carmelo Cascone | 3dcb7fd | 2019-06-26 14:08:36 -0700 | [diff] [blame] | 37 | 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 Cascone | 395b231 | 2019-06-18 17:34:16 -0700 | [diff] [blame] | 42 | output_to_bindir = True, |
| 43 | toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"], |
| 44 | visibility = ["//visibility:public"], |
| 45 | ) |
| 46 | |
| 47 | filegroup( |
| 48 | name = "conf-security", |
| 49 | srcs = glob(["conf/security/**"]), |
| 50 | ) |