diff --git a/.bazelrc b/.bazelrc index 64f85c8a8a..266386afc3 100644 --- a/.bazelrc +++ b/.bazelrc @@ -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 diff --git a/WORKSPACE b/WORKSPACE index aeadecc3b8..c03b7d3ed0 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -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() diff --git a/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java b/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java index 8a314463f5..f565f0a640 100644 --- a/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java +++ b/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java @@ -390,9 +390,9 @@ public class GossipDeviceStoreTest { DeviceDescription description = new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, HW, SW1, SN, CID); - Capture message = new Capture<>(); - Capture subject = new Capture<>(); - Capture> encoder = new Capture<>(); + Capture message = Capture.newInstance(); + Capture subject = Capture.newInstance(); + Capture> 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 bcast = new Capture<>(); + Capture bcast = Capture.newInstance(); - Capture message = new Capture<>(); - Capture subject = new Capture<>(); - Capture> encoder = new Capture<>(); + Capture message = Capture.newInstance(); + Capture subject = Capture.newInstance(); + Capture> 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 message = new Capture<>(); - Capture subject = new Capture<>(); - Capture> encoder = new Capture<>(); + Capture message = Capture.newInstance(); + Capture subject = Capture.newInstance(); + Capture> 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 message = new Capture<>(); - Capture subject = new Capture<>(); - Capture> encoder = new Capture<>(); + Capture message = Capture.newInstance(); + Capture subject = Capture.newInstance(); + Capture> encoder = Capture.newInstance(); resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); List events = deviceStore.updatePorts(PID, DID1, pds); @@ -611,9 +611,9 @@ public class GossipDeviceStoreTest { ); deviceStore.updatePorts(PID, DID1, pds); - Capture message = new Capture<>(); - Capture subject = new Capture<>(); - Capture> encoder = new Capture<>(); + Capture message = Capture.newInstance(); + Capture subject = Capture.newInstance(); + Capture> 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 message = new Capture<>(); - Capture subject = new Capture<>(); - Capture> encoder = new Capture<>(); + Capture message = Capture.newInstance(); + Capture subject = Capture.newInstance(); + Capture> 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 message = new Capture<>(); - Capture subject = new Capture<>(); - Capture> encoder = new Capture<>(); + Capture message = Capture.newInstance(); + Capture subject = Capture.newInstance(); + Capture> encoder = Capture.newInstance(); resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); diff --git a/lib/deps.json b/lib/deps.json index 38aed00d69..b5e26f6b4e 100644 --- a/lib/deps.json +++ b/lib/deps.json @@ -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", diff --git a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSshdTestSubsystem.java b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSshdTestSubsystem.java index e10b82e4d8..b8797b8d81 100644 --- a/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSshdTestSubsystem.java +++ b/protocols/netconf/ctl/src/test/java/org/onosproject/netconf/ctl/impl/NetconfSshdTestSubsystem.java @@ -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 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; diff --git a/tools/build/bazel/BUILD b/tools/build/bazel/BUILD index d819d631e9..cf2024640e 100644 --- a/tools/build/bazel/BUILD +++ b/tools/build/bazel/BUILD @@ -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"], diff --git a/tools/build/bazel/bazel_version.bzl b/tools/build/bazel/bazel_version.bzl index 49434bf54d..9a0046e0ce 100644 --- a/tools/build/bazel/bazel_version.bzl +++ b/tools/build/bazel/bazel_version.bzl @@ -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) diff --git a/tools/build/bazel/generate_workspace.bzl b/tools/build/bazel/generate_workspace.bzl index c1779939e8..086ebea353 100644 --- a/tools/build/bazel/generate_workspace.bzl +++ b/tools/build/bazel/generate_workspace.bzl @@ -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" diff --git a/tools/build/bazel/osgi_java_library.bzl b/tools/build/bazel/osgi_java_library.bzl index 37200643cc..8296fcf71d 100644 --- a/tools/build/bazel/osgi_java_library.bzl +++ b/tools/build/bazel/osgi_java_library.bzl @@ -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() diff --git a/tools/dev/bin/onos-gen-bazel-project b/tools/dev/bin/onos-gen-bazel-project index 0c33da1e80..355193a39b 100755 --- a/tools/dev/bin/onos-gen-bazel-project +++ b/tools/dev/bin/onos-gen-bazel-project @@ -3,7 +3,7 @@ import os import subprocess -JAVA_LANGUAGE_LEVEL = 8 +JAVA_LANGUAGE_LEVEL = 11 EXCLUDE_DIRECTORIES = ( "target",