[SDFAB-1196] Build ONOS with Bazel 6.0.0 pre-release
This was a quite big jump (3.7.2 -> 6.x.x) and we had
to face the deprecation of several components.
- javabase/host_javabase -> java_language_version and
java_runtime_version
- java_toolchain/host_java_toolchain -> java_language_version
and java_runtime_version
- Turnedoff "ReturnValueIgnored" related to ErrorProne
- Moved to bazelisk v1.11.0
- patched again the grpc code due to the deprecation of host_javabase
as java_toolcahin contains already this information.
- resource_jars are also handled as resources because java constructs
do not accept them anymore.
- Use the OSGIWrapper to fix the path of the resource_hars and untar them.
Additionally clean up the code and enable/disable logging through a param.
- Fix absolute_javabase in the Dockerfile by providing the absolute
path of the local jvm through local_java_repository. The latter is
appended to the WORKSPACE file on demand inside the Dockerfile.
Change-Id: I96e06fe52b3b49a1a34f01443eec583a95347323
diff --git a/tools/build/bazel/grpc_workspace.bzl b/tools/build/bazel/grpc_workspace.bzl
index f2f3dfc..1a680da 100644
--- a/tools/build/bazel/grpc_workspace.bzl
+++ b/tools/build/bazel/grpc_workspace.bzl
@@ -1,7 +1,7 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
GRPC_JAVA_VERSION = "1.22.1"
-GRPC_SHA = "e6915ea60ab8a6e17de86bd94a8db320b0115cc214db19bef8f2ba4af2dab430"
+GRPC_SHA = "073395219d611c21a460d21dfe5cb77550030d6396b400f796e568b5175c2ec0"
GAPIS_COMMIT = "37cc0e5acae50ee91f00827a7010c3b07dfa5311"
GAPIS_SHA = "17d023f48ea290f25edaf25a967973b5a42ce6d71b1570862f302d95aa8b9f77"
@@ -10,9 +10,9 @@
# grpc-java fork that fixes the OSGi split brain problem.
http_archive(
name = "io_grpc_grpc_java",
- urls = ["https://github.com/opennetworkinglab/grpc-java/archive/v%s-patched.zip" % GRPC_JAVA_VERSION],
+ urls = ["https://github.com/opennetworkinglab/grpc-java/archive/v%s-fix-host_javabase.zip" % GRPC_JAVA_VERSION],
sha256 = GRPC_SHA,
- strip_prefix = "grpc-java-%s-patched" % GRPC_JAVA_VERSION,
+ strip_prefix = "grpc-java-%s-fix-host_javabase" % GRPC_JAVA_VERSION,
)
# Google APIs protos (status.proto, etc.)
diff --git a/tools/build/bazel/osgi_java_library.bzl b/tools/build/bazel/osgi_java_library.bzl
index 491444f..0236db4 100644
--- a/tools/build/bazel/osgi_java_library.bzl
+++ b/tools/build/bazel/osgi_java_library.bzl
@@ -124,6 +124,8 @@
bundle_classpath,
karaf_commands,
fragment_host,
+ # enable/disable osgi-wrap logging
+ "false",
]
ctx.actions.run(
@@ -507,7 +509,7 @@
native.java_library(
name = name + "-native",
srcs = native_srcs,
- resource_jars = resource_jars + [name + "_cfgdef_jar"],
+ resources = resource_jars + [name + "_cfgdef_jar"],
deps = deps,
visibility = visibility,
javacopts = javacopts,
@@ -516,13 +518,14 @@
native.java_library(
name = name + "-native",
srcs = native_srcs,
- resource_jars = [name + "_cfgdef_jar"],
- resources = native_resources,
+ resources = native_resources + [name + "_cfgdef_jar"],
deps = deps,
visibility = visibility,
javacopts = javacopts,
)
+ # NOTE that the additional resource_jars are modified by
+ # osgi-wrap because java_library does not decompress them.
karaf_command_packages_string = ",".join(karaf_command_packages)
_bnd(
name = name,
diff --git a/tools/build/bazel/topo_BUILD b/tools/build/bazel/topo_BUILD
index 9a42836..a3418b2 100644
--- a/tools/build/bazel/topo_BUILD
+++ b/tools/build/bazel/topo_BUILD
@@ -16,6 +16,6 @@
name = "topo_device_proto_sed",
srcs = [":device/device.proto"],
outs = ["new/device/device.proto"],
- cmd = "sed -e 's:import \"gogoproto.*;::g;s: ..gogoproto\..*:;:g;s:import \"%s:import \":g;s:^syntax = \"proto3\";:&\\\n option java_package = \"org.onosproject.uonos\";:g' $(location :device/device.proto) >> \"$@\""
+ cmd = "sed -e 's:import \"gogoproto.*;::g;s: ..gogoproto\\..*:;:g;s:import \"%s:import \":g;s:^syntax = \"proto3\";:&\\\n option java_package = \"org.onosproject.uonos\";:g' $(location :device/device.proto) >> \"$@\""
% IMPORT_PREFIX,
)
diff --git a/tools/build/jdk/BUILD b/tools/build/jdk/BUILD
index 0055031..c99f398 100644
--- a/tools/build/jdk/BUILD
+++ b/tools/build/jdk/BUILD
@@ -1,24 +1,3 @@
-# This is where we define the JDK used to build ONOS, as well as the language
-# source and target values passed to javac. The :default_toolchain and
-# :default_jdk are expected to be passed as arguments when invoking bazel build
-# (see onos/.bazelrc)
-
-load("//tools/build/bazel:variables.bzl", "DEFAULT_JAVA_VERSION")
-load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain")
-
-default_java_toolchain(
- name = "default_toolchain",
- source_version = DEFAULT_JAVA_VERSION,
- target_version = DEFAULT_JAVA_VERSION,
- visibility = ["//visibility:public"],
-)
-
-alias(
- name = "default_jdk",
- actual = "@bazel_tools//tools/jdk:remote_jdk11",
- visibility = ["//visibility:public"],
-)
-
# We use the following rule to package the same JDK used for building and make
# it available for external scripts as their JAVA_HOME, such as for `bazel run
# onos-local`.
diff --git a/tools/dev/Dockerfile-yourkit b/tools/dev/Dockerfile-yourkit
index d54460e..176c3b3 100644
--- a/tools/dev/Dockerfile-yourkit
+++ b/tools/dev/Dockerfile-yourkit
@@ -41,7 +41,7 @@
# Install Bazelisk, which will download the version of bazel specified in
# .bazelversion
-RUN curl -L -o bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.5.0/bazelisk-linux-amd64
+RUN curl -L -o bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.11.0/bazelisk-linux-amd64
RUN chmod +x bazelisk && mv bazelisk /usr/bin
# Build-stage environment variables
@@ -56,16 +56,15 @@
# Build ONOS using the JDK pre-installed in the base image, instead of the
# Bazel-provided remote one. By doing wo we make sure to build with the most
# updated JDK, including bug and security fixes, independently of the Bazel
-# version.
+# version. NOTE that WORKSPACE-docker file defines dockerjdk
ARG JOBS
ARG JAVA_PATH
ARG PROFILE
-RUN bazelisk build onos \
+RUN cat WORKSPACE-docker >> WORKSPACE && bazelisk build onos \
--jobs ${JOBS} \
--verbose_failures \
- --javabase=@bazel_tools//tools/jdk:absolute_javabase \
- --host_javabase=@bazel_tools//tools/jdk:absolute_javabase \
- --define=ABSOLUTE_JAVABASE=${JAVA_PATH} \
+ --java_runtime_version=dockerjdk_11 \
+ --tool_java_runtime_version=dockerjdk_11 \
--define profile=${PROFILE}
# We extract the tar in the build environment to avoid having to put the tar in