Enforce build with Java 11 for all by default

- Build with JDK11 and language levels (source and target) are now
enforced in .bazelrc, which depends on our own Java toolchain (defined
in tools/build/bazel/BUILD)
- Easymock bumped to v4.0.2 with support for Java 11 (minor API changes)
- The minimum required Bazel version is now 0.27.*

Change-Id: I0bb6dfe7fc1ea134b5a53dd249c369d58259688c
This commit is contained in:
Carmelo Cascone 2019-06-17 12:00:33 -07:00 committed by Ray Milkey
parent 46fcbe4b91
commit 21eb042dba
10 changed files with 93 additions and 67 deletions

View File

@ -1,12 +1,16 @@
# Build options to use JDK 11
# build --incompatible_use_jdk11_as_host_javabase
# build --javabase=@bazel_tools//tools/jdk:remote_jdk11
# build --host_javabase=@bazel_tools//tools/jdk:remote_jdk11
# build --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla
# build --java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla
build --javabase=@bazel_tools//tools/jdk:remote_jdk11
build --host_javabase=@bazel_tools//tools/jdk:remote_jdk11
build --java_toolchain=@org_onosproject_onos//tools/build/bazel:default_toolchain
build --host_java_toolchain=@org_onosproject_onos//tools/build/bazel:default_toolchain
build --nouse_ijars
build --experimental_strict_action_env
# io_bazel_rules_go needs this
build --incompatible_disable_deprecated_attr_params=false
# intellij-bazel plugin needs this
build --incompatible_depset_is_not_iterable=false
build --incompatible_new_actions_api=false
test --test_summary=terse
test --test_output=errors
test --test_verbose_timeout_warnings

View File

@ -117,10 +117,18 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# See https://github.com/bazelbuild/rules_go for the up to date setup instructions.
http_archive(
name = "io_bazel_rules_go",
sha256 = "b7a62250a3a73277ade0ce306d22f122365b513f5402222403e507f2f997d421",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.16.3/rules_go-0.16.3.tar.gz",
sha256 = "f04d2373bcaf8aa09bccb08a98a57e721306c8f6043a2a0ee610fd6853dcde3d",
urls = [
"https://github.com/bazelbuild/rules_go/releases/download/0.18.6/rules_go-0.18.6.tar.gz",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains()
http_archive(
name = "com_github_bazelbuild_buildtools",
sha256 = "e0b5b400cfef17d65886365dc7289cb4ef8dfe07066165607413a271a32aa2a4",
@ -128,11 +136,6 @@ http_archive(
url = "https://github.com/bazelbuild/buildtools/archive/db073457c5a56d810e46efc18bb93a4fd7aa7b5e.zip",
)
load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@com_github_bazelbuild_buildtools//buildifier:deps.bzl", "buildifier_dependencies")
go_rules_dependencies()
go_register_toolchains()
buildifier_dependencies()

View File

@ -390,9 +390,9 @@ public class GossipDeviceStoreTest {
DeviceDescription description =
new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
HW, SW1, SN, CID);
Capture<InternalDeviceEvent> message = new Capture<>();
Capture<MessageSubject> subject = new Capture<>();
Capture<Function<InternalDeviceEvent, byte[]>> encoder = new Capture<>();
Capture<InternalDeviceEvent> message = Capture.newInstance();
Capture<MessageSubject> subject = Capture.newInstance();
Capture<Function<InternalDeviceEvent, byte[]>> encoder = Capture.newInstance();
resetCommunicatorExpectingSingleBroadcast(message, subject, encoder);
DeviceEvent event = deviceStore.createOrUpdateDevice(PID, DID1, description);
@ -423,11 +423,11 @@ public class GossipDeviceStoreTest {
DeviceDescription description =
new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
HW, SW1, SN, CID, A2);
Capture<ClusterMessage> bcast = new Capture<>();
Capture<ClusterMessage> bcast = Capture.newInstance();
Capture<InternalDeviceEvent> message = new Capture<>();
Capture<MessageSubject> subject = new Capture<>();
Capture<Function<InternalDeviceEvent, byte[]>> encoder = new Capture<>();
Capture<InternalDeviceEvent> message = Capture.newInstance();
Capture<MessageSubject> subject = Capture.newInstance();
Capture<Function<InternalDeviceEvent, byte[]>> encoder = Capture.newInstance();
resetCommunicatorExpectingSingleBroadcast(message, subject, encoder);
DeviceEvent event = deviceStore.createOrUpdateDevice(PIDA, DID1, description);
@ -497,9 +497,9 @@ public class GossipDeviceStoreTest {
putDevice(DID1, SW1);
assertTrue(deviceStore.isAvailable(DID1));
Capture<InternalDeviceEvent> message = new Capture<>();
Capture<MessageSubject> subject = new Capture<>();
Capture<Function<InternalDeviceEvent, byte[]>> encoder = new Capture<>();
Capture<InternalDeviceEvent> message = Capture.newInstance();
Capture<MessageSubject> subject = Capture.newInstance();
Capture<Function<InternalDeviceEvent, byte[]>> encoder = Capture.newInstance();
resetCommunicatorExpectingSingleBroadcast(message, subject, encoder);
DeviceEvent event = deviceStore.markOffline(DID1);
@ -525,9 +525,9 @@ public class GossipDeviceStoreTest {
DefaultPortDescription.builder().withPortNumber(P1).isEnabled(true).build(),
DefaultPortDescription.builder().withPortNumber(P2).isEnabled(true).build()
);
Capture<InternalDeviceEvent> message = new Capture<>();
Capture<MessageSubject> subject = new Capture<>();
Capture<Function<InternalDeviceEvent, byte[]>> encoder = new Capture<>();
Capture<InternalDeviceEvent> message = Capture.newInstance();
Capture<MessageSubject> subject = Capture.newInstance();
Capture<Function<InternalDeviceEvent, byte[]>> encoder = Capture.newInstance();
resetCommunicatorExpectingSingleBroadcast(message, subject, encoder);
List<DeviceEvent> events = deviceStore.updatePorts(PID, DID1, pds);
@ -611,9 +611,9 @@ public class GossipDeviceStoreTest {
);
deviceStore.updatePorts(PID, DID1, pds);
Capture<InternalPortStatusEvent> message = new Capture<>();
Capture<MessageSubject> subject = new Capture<>();
Capture<Function<InternalPortStatusEvent, byte[]>> encoder = new Capture<>();
Capture<InternalPortStatusEvent> message = Capture.newInstance();
Capture<MessageSubject> subject = Capture.newInstance();
Capture<Function<InternalPortStatusEvent, byte[]>> encoder = Capture.newInstance();
resetCommunicatorExpectingSingleBroadcast(message, subject, encoder);
final DefaultPortDescription desc = DefaultPortDescription.builder().withPortNumber(P1)
@ -637,9 +637,9 @@ public class GossipDeviceStoreTest {
);
deviceStore.updatePorts(PID, DID1, pds);
Capture<InternalPortStatusEvent> message = new Capture<>();
Capture<MessageSubject> subject = new Capture<>();
Capture<Function<InternalPortStatusEvent, byte[]>> encoder = new Capture<>();
Capture<InternalPortStatusEvent> message = Capture.newInstance();
Capture<MessageSubject> subject = Capture.newInstance();
Capture<Function<InternalPortStatusEvent, byte[]>> encoder = Capture.newInstance();
// update port from primary
resetCommunicatorExpectingSingleBroadcast(message, subject, encoder);
@ -817,9 +817,9 @@ public class GossipDeviceStoreTest {
assertAnnotationsEquals(deviceStore.getDevice(DID1).annotations(), A1);
assertAnnotationsEquals(deviceStore.getPort(DID1, P1).annotations(), A2);
Capture<InternalDeviceEvent> message = new Capture<>();
Capture<MessageSubject> subject = new Capture<>();
Capture<Function<InternalDeviceEvent, byte[]>> encoder = new Capture<>();
Capture<InternalDeviceEvent> message = Capture.newInstance();
Capture<MessageSubject> subject = Capture.newInstance();
Capture<Function<InternalDeviceEvent, byte[]>> encoder = Capture.newInstance();
resetCommunicatorExpectingSingleBroadcast(message, subject, encoder);

View File

@ -151,7 +151,7 @@
"commons-pool": "mvn:commons-pool:commons-pool:1.6",
"commons-text": "mvn:org.apache.commons:commons-text:1.3",
"concurrent-trees": "mvn:com.googlecode.concurrent-trees:concurrent-trees:2.6.1",
"easymock": "mvn:org.easymock:easymock:3.6",
"easymock": "mvn:org.easymock:easymock:4.0.2",
"antlr": "mvn:antlr:antlr:2.7.7",
"ganymed-ssh2": "mvn:ch.ethz.ganymed:ganymed-ssh2:262",
"gmetric4j": "mvn:info.ganglia.gmetric4j:gmetric4j:1.0.10",

View File

@ -16,22 +16,6 @@
package org.onosproject.netconf.ctl.impl;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.EOFException;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.regex.Pattern;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.util.threads.ThreadUtils;
@ -45,6 +29,22 @@ import org.onosproject.netconf.ctl.impl.NetconfStreamThread.NetconfMessageState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.regex.Pattern;
/**
* Mocks a NETCONF Device to test the NETCONF Southbound Interface etc.
*
@ -464,12 +464,17 @@ public class NetconfSshdTestSubsystem extends Thread implements Command, Runnabl
@Override
public void interrupt() {
destroy();
}
@Override
public void destroy() {
// if thread has not completed, cancel it
if ((pendingFuture != null) && (!pendingFuture.isDone())) {
boolean result = pendingFuture.cancel(true);
// TODO consider waiting some reasonable (?) amount of time for cancellation
if (log.isDebugEnabled()) {
log.debug("interrupt() - cancel pending future=" + result);
log.debug("destroy() - cancel pending future=" + result);
}
}
@ -478,8 +483,8 @@ public class NetconfSshdTestSubsystem extends Thread implements Command, Runnabl
if ((executors != null) && shutdownExecutor) {
Collection<Runnable> runners = executors.shutdownNow();
if (log.isDebugEnabled()) {
log.debug("interrupt() - shutdown executor service - runners count=" +
runners.size());
log.debug("destroy() - shutdown executor service - runners count=" +
runners.size());
}
}
@ -487,7 +492,7 @@ public class NetconfSshdTestSubsystem extends Thread implements Command, Runnabl
if (!closed) {
if (log.isDebugEnabled()) {
log.debug("interrupt() - mark as closed");
log.debug("destroy() - mark as closed");
}
closed = true;

View File

@ -1,3 +1,17 @@
load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain")
# This is where we define the language source and target values passed to javac
# when building ONOS. This toolchain should be used when invoking bazel build
# (see onos/.bazelrc)
default_java_toolchain(
name = "default_toolchain",
source_version = "11",
target_version = "11",
visibility = [
"//visibility:public",
],
)
py_binary(
name = "osgi_feature_bundler",
srcs = ["osgi_feature_bundler.py"],

View File

@ -16,12 +16,12 @@
def check_bazel_version():
if "bazel_version" not in dir(native):
fail("\nBazel version is too old; please use 0.23.* official release!\n\n")
fail("\nBazel version is too old; please use 0.27.* official release!\n\n")
elif not native.bazel_version:
print("\nBazel is not a release version; please use 0.23.* official release!\n\n")
print("\nBazel is not a release version; please use 0.27.* official release!\n\n")
return
versions = native.bazel_version.split(".")
if not int(versions[1]) >= 23:
fail("\nBazel version %s is not supported; please use 0.23.* official release!\n\n" %
if not int(versions[1]) >= 27:
fail("\nBazel version %s is not supported; please use 0.27.* official release!\n\n" %
native.bazel_version)

View File

@ -1,4 +1,4 @@
# ***** This file was auto-generated at Wed, 29 May 2019 22:17:30 GMT. Do not edit this file manually. *****
# ***** This file was auto-generated at Mon, 17 Jun 2019 19:13:01 GMT. Do not edit this file manually. *****
# ***** Use onos-lib-gen *****
load("//tools/build/bazel:variables.bzl", "ONOS_GROUP_ID", "ONOS_VERSION")
@ -295,9 +295,9 @@ def generated_maven_jars():
if "easymock" not in native.existing_rules():
java_import_external(
name = "easymock",
jar_sha256 = "0557c9fa845c951bdbe3940b605346a212172c64328277428297ef1fc6308e8f",
jar_sha256 = "104370107ef64d115e642cbdc14cea438a8d076f5aee9a9cb7882dc9a8ed4123",
licenses = ["notice"],
jar_urls = ["http://repo1.maven.org/maven2/org/easymock/easymock/3.6/easymock-3.6.jar"], )
jar_urls = ["http://repo1.maven.org/maven2/org/easymock/easymock/4.0.2/easymock-4.0.2.jar"], )
if "antlr" not in native.existing_rules():
java_import_external(
name = "antlr",
@ -1353,7 +1353,7 @@ artifact_map["@commons_net//:commons_net"] = "mvn:commons-net:commons-net:jar:3.
artifact_map["@commons_pool//:commons_pool"] = "mvn:commons-pool:commons-pool:jar:1.6"
artifact_map["@commons_text//:commons_text"] = "mvn:org.apache.commons:commons-text:jar:1.3"
artifact_map["@concurrent_trees//:concurrent_trees"] = "mvn:com.googlecode.concurrent-trees:concurrent-trees:jar:2.6.1"
artifact_map["@easymock//:easymock"] = "mvn:org.easymock:easymock:jar:3.6"
artifact_map["@easymock//:easymock"] = "mvn:org.easymock:easymock:jar:4.0.2"
artifact_map["@antlr//:antlr"] = "mvn:antlr:antlr:jar:NON-OSGI:2.7.7"
artifact_map["@ganymed_ssh2//:ganymed_ssh2"] = "mvn:ch.ethz.ganymed:ganymed-ssh2:jar:NON-OSGI:262"
artifact_map["@gmetric4j//:gmetric4j"] = "mvn:info.ganglia.gmetric4j:gmetric4j:jar:1.0.10"

View File

@ -448,7 +448,7 @@ def osgi_jar_with_tests(
if import_packages == None:
import_packages = "*"
tests_name = name + "-tests"
tests_jar_deps = list(depset(deps + test_deps)) + [name]
tests_jar_deps = depset(deps + test_deps).to_list() + [name]
all_test_deps = tests_jar_deps + [tests_name]
web_xml = _webapp()

View File

@ -3,7 +3,7 @@ import os
import subprocess
JAVA_LANGUAGE_LEVEL = 8
JAVA_LANGUAGE_LEVEL = 11
EXCLUDE_DIRECTORIES = (
"target",