Revamp support for building third-party apps via maven
- Publish onos-dependencies (autogenerated from deps.json). With most
3rd-party dependencies listed as <dependencyManagement> to avoid
version conflicts, and a minimal set listed as <dependencies> to
simplify child poms. Similarly, we provide a number of plugins already
configured as <pluginManagement> to support the whole life-cycle of
apps (from build, to reporting and release).
- Update Maven plugins to work with JDK 11 (checkstyle, pmd, etc.)
- Publish onos-build-conf (with common checkstyle and pmd confs)
- Removed unused checkstyle code
- Fix OSGi version mismatch in deps.json to consistently depend on
release 6 (the one supported by Karaf 4)
- Update/simplify archetypes to use onos-dependencies as the parent pom
Change-Id: Ic09b34e13fb49eb3d96df623b53a3617bbf7b7e4
diff --git a/tools/build/bazel/BUILD b/tools/build/bazel/BUILD
index d819d63..26590a7 100644
--- a/tools/build/bazel/BUILD
+++ b/tools/build/bazel/BUILD
@@ -26,6 +26,13 @@
visibility = ["//visibility:public"],
)
+py_binary(
+ name = "dependencies_pom_generator",
+ srcs = ["dependencies_pom_generator.py"],
+ main = "dependencies_pom_generator.py",
+ visibility = ["//visibility:public"],
+)
+
java_binary(
name = "onos_yang_compiler",
main_class = "org.onosproject.yang.compiler.main.YangCompilerMain",
diff --git a/tools/build/bazel/dependencies_pom_generator.py b/tools/build/bazel/dependencies_pom_generator.py
new file mode 100755
index 0000000..f2df0c2
--- /dev/null
+++ b/tools/build/bazel/dependencies_pom_generator.py
@@ -0,0 +1,124 @@
+#!/usr/bin/env python
+# Copyright 2019-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import argparse
+from datetime import datetime
+from xml.dom import minidom
+
+
+def resolve(mvn_coord):
+ mvn_pieces = mvn_coord.split(":")
+ if mvn_pieces[0] != "mvn":
+ raise ("Invalid Maven coordinate: %s" % mvn_coord)
+ return dict(
+ groupId=mvn_pieces[1],
+ artifactId=mvn_pieces[2],
+ version=mvn_pieces[-1],
+ name=mvn_coord,
+ )
+
+
+def xml_beautify(data):
+ beautified = '\n'.join([
+ l for l in
+ minidom.parseString(data).toprettyxml(indent=' ' * 4).split('\n')
+ if l.strip()])
+ return beautified
+
+
+def generate_pom(out_file, template_file, provided_deps, test_deps, deps, var_dict):
+ deps = {d: resolve(d) for d in deps}
+
+ dep_mgmt_template = """
+ <dependency>
+ <!-- {name} -->
+ <groupId>{groupId}</groupId>
+ <artifactId>{artifactId}</artifactId>
+ <version>{version}</version>
+ </dependency>"""
+
+ dep_template = """
+ <dependency>
+ <!-- {name} -->
+ <groupId>{groupId}</groupId>
+ <artifactId>{artifactId}</artifactId>
+ <scope>{scope}</scope>
+ </dependency>"""
+
+ mgmt_deps = sorted(deps.keys())
+ provided_deps.sort()
+ test_deps.sort()
+
+ with open(template_file, "r") as f:
+ lines = f.readlines()
+
+ new_lines = [
+ "<!-- Automatically generated on %s -->"
+ % datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+ ]
+ for line in lines:
+ if "<!-- DEPS_MGMT -->" in line:
+ new_lines.extend([
+ dep_mgmt_template.format(**deps[x]) for x in mgmt_deps])
+ elif "<!-- DEPS -->" in line:
+ new_lines.extend([
+ dep_template.format(scope='provided', **deps[x])
+ for x in provided_deps])
+ new_lines.extend([
+ dep_template.format(scope='test', **deps[x])
+ for x in test_deps])
+ else:
+ for old, new in var_dict.items():
+ line = line.replace(old, new)
+ new_lines.append(line)
+
+ with open(out_file, 'w') as f:
+ f.write(xml_beautify("\n".join(new_lines)))
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-o', dest='out_file', type=str, action="store",
+ required=True, help="Path to output file")
+ parser.add_argument('-p', dest='template_file', type=str, action="store",
+ required=True, help="Path to pom template file")
+ parser.add_argument('-c', dest='provided_deps', metavar='PROVIDED_DEP',
+ type=str, nargs='+', default=[],
+ help='Maven coordinates to list with scope provided')
+ parser.add_argument('-t', dest='test_deps', metavar='TEST_DEP', type=str,
+ nargs='+', default=[],
+ help='Maven coordinates to list with scope test')
+ parser.add_argument('-d', dest='deps', metavar='DEP', type=str,
+ nargs='+', default=[],
+ help='Maven coordinates to list under <dependencyManagement>')
+ parser.add_argument('-v', dest='vars', metavar='VAR=value', type=str,
+ nargs='+', default=[],
+ help='Replace all instances of <!-- VAR --> with the given value')
+ args = parser.parse_args()
+
+ processed_vars = {}
+ for var in args.vars:
+ pieces = var.split('=')
+ if len(pieces) != 2:
+ raise ("Invalid var '%s'" % var)
+ processed_vars["<!-- %s -->" % pieces[0]] = pieces[1]
+
+ generate_pom(
+ out_file=args.out_file,
+ template_file=args.template_file,
+ provided_deps=args.provided_deps,
+ test_deps=args.test_deps,
+ deps=args.deps,
+ var_dict=processed_vars
+ )
diff --git a/tools/build/bazel/generate_workspace.bzl b/tools/build/bazel/generate_workspace.bzl
index 78d96c9..93fc83a 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 Thu, 29 Aug 2019 08:32:49 GMT. Do not edit this file manually. *****
+# ***** This file was auto-generated at Fri, 15 Nov 2019 18:42:10 GMT. Do not edit this file manually. *****
# ***** Use onos-lib-gen *****
load("//tools/build/bazel:variables.bzl", "ONOS_GROUP_ID", "ONOS_VERSION")
@@ -835,9 +835,9 @@
if "org_osgi_util_promise" not in native.existing_rules():
java_import_external(
name = "org_osgi_util_promise",
- jar_sha256 = "a679e25688e84e1739831e8716a2cc7acbf8348e22f1136d1988e34472e43756",
+ jar_sha256 = "4f85beccd281cc1a4e735bd266a0dd3db11651d3d0dde001e6bfa55dbdfdee83",
licenses = ["notice"],
- jar_urls = ["http://repo1.maven.org/maven2/org/osgi/org.osgi.util.promise/1.1.0/org.osgi.util.promise-1.1.0.jar"], )
+ jar_urls = ["http://repo1.maven.org/maven2/org/osgi/org.osgi.util.promise/1.1.1/org.osgi.util.promise-1.1.1.jar"], )
if "org_osgi_service_component" not in native.existing_rules():
java_import_external(
name = "org_osgi_service_component",
@@ -916,24 +916,18 @@
jar_sha256 = "68c5b7885fa9157813e01482ddbdfa1c63bb6743d98fd5dba8ce83904bfcf7f8",
licenses = ["notice"],
jar_urls = ["http://repo1.maven.org/maven2/org/apache/servicemix/bundles/org.apache.servicemix.bundles.snmp4j/2.3.4_1/org.apache.servicemix.bundles.snmp4j-2.3.4_1.jar"], )
- if "org_osgi_compendium" not in native.existing_rules():
- java_import_external(
- name = "org_osgi_compendium",
- jar_sha256 = "f1ef32cc1530f4e66aac606c24363b627ace4780a7737b045bfb3b908d801bcd",
- licenses = ["notice"],
- jar_urls = ["http://repo1.maven.org/maven2/org/osgi/org.osgi.compendium/5.0.0/org.osgi.compendium-5.0.0.jar"], )
if "org_osgi_cmpn" not in native.existing_rules():
java_import_external(
name = "org_osgi_cmpn",
- jar_sha256 = "8e6445afe1abb3dcd43c60c8cd6c0f15b052a8f4228812559ba521c5ce91db34",
+ jar_sha256 = "dbe06105a0e3e46bc88425b3d7c682a2d8b6bd055341913b6c37e998c00c9176",
licenses = ["notice"],
- jar_urls = ["http://repo1.maven.org/maven2/org/osgi/osgi.cmpn/7.0.0/osgi.cmpn-7.0.0.jar"], )
+ jar_urls = ["http://repo1.maven.org/maven2/org/osgi/osgi.cmpn/6.0.0/osgi.cmpn-6.0.0.jar"], )
if "osgi_core" not in native.existing_rules():
java_import_external(
name = "osgi_core",
- jar_sha256 = "b440c6bff286332afcf5cae067b606962e761c0df00e5fd8a746f0b31265619b",
+ jar_sha256 = "1c1bb435eb34cbf1f743653da38f604d45d53fbc95979053768cd3fc293cb931",
licenses = ["notice"],
- jar_urls = ["http://repo1.maven.org/maven2/org/osgi/org.osgi.core/5.0.0/org.osgi.core-5.0.0.jar"], )
+ jar_urls = ["http://repo1.maven.org/maven2/org/osgi/org.osgi.core/6.0.0/org.osgi.core-6.0.0.jar"], )
if "reflectasm" not in native.existing_rules():
java_import_external(
name = "reflectasm",
@@ -1449,7 +1443,7 @@
artifact_map["@objenesis//:objenesis"] = "mvn:org.objenesis:objenesis:jar:2.6"
artifact_map["@openflowj//:openflowj"] = "mvn:org.onosproject:openflowj:jar:3.2.1.onos"
artifact_map["@org_osgi_util_function//:org_osgi_util_function"] = "mvn:org.osgi:org.osgi.util.function:jar:1.1.0"
-artifact_map["@org_osgi_util_promise//:org_osgi_util_promise"] = "mvn:org.osgi:org.osgi.util.promise:jar:1.1.0"
+artifact_map["@org_osgi_util_promise//:org_osgi_util_promise"] = "mvn:org.osgi:org.osgi.util.promise:jar:1.1.1"
artifact_map["@org_osgi_service_component//:org_osgi_service_component"] = "mvn:org.osgi:org.osgi.service.component:jar:1.4.0"
artifact_map["@org_osgi_service_component_annotations//:org_osgi_service_component_annotations"] = "mvn:org.osgi:org.osgi.service.component.annotations:jar:1.4.0"
artifact_map["@org_osgi_service_metatype_annotations//:org_osgi_service_metatype_annotations"] = "mvn:org.osgi:org.osgi.service.metatype.annotations:jar:1.4.0"
@@ -1463,9 +1457,8 @@
artifact_map["@org_apache_karaf_jaas//:org_apache_karaf_jaas"] = "mvn:org.apache.karaf.jaas:org.apache.karaf.jaas.modules:jar:4.2.6"
artifact_map["@org_apache_karaf_system_core//:org_apache_karaf_system_core"] = "mvn:org.apache.karaf.system:org.apache.karaf.system.core:jar:4.2.6"
artifact_map["@org_apache_servicemix_bundles_snmp4j//:org_apache_servicemix_bundles_snmp4j"] = "mvn:org.apache.servicemix.bundles:org.apache.servicemix.bundles.snmp4j:jar:2.3.4_1"
-artifact_map["@org_osgi_compendium//:org_osgi_compendium"] = "mvn:org.osgi:org.osgi.compendium:jar:5.0.0"
-artifact_map["@org_osgi_cmpn//:org_osgi_cmpn"] = "mvn:org.osgi:osgi.cmpn:jar:7.0.0"
-artifact_map["@osgi_core//:osgi_core"] = "mvn:org.osgi:org.osgi.core:jar:5.0.0"
+artifact_map["@org_osgi_cmpn//:org_osgi_cmpn"] = "mvn:org.osgi:osgi.cmpn:jar:6.0.0"
+artifact_map["@osgi_core//:osgi_core"] = "mvn:org.osgi:org.osgi.core:jar:6.0.0"
artifact_map["@reflectasm//:reflectasm"] = "mvn:com.esotericsoftware:reflectasm:jar:1.11.7"
artifact_map["@remotetea_oncrpc//:remotetea_oncrpc"] = "mvn:org.acplt.remotetea:remotetea-oncrpc:jar:1.1.3"
artifact_map["@rrd4j//:rrd4j"] = "mvn:org.rrd4j:rrd4j:jar:NON-OSGI:3.1"
diff --git a/tools/build/bazel/pom_file.bzl b/tools/build/bazel/pom_file.bzl
index e3c5689..c291d4c 100644
--- a/tools/build/bazel/pom_file.bzl
+++ b/tools/build/bazel/pom_file.bzl
@@ -14,7 +14,7 @@
load("//tools/build/bazel:generate_workspace.bzl", "maven_coordinates")
-def _impl(ctx):
+def _impl_pom_file(ctx):
arguments = [
ctx.outputs.pom.path,
maven_coordinates(ctx.attr.artifact),
@@ -42,6 +42,47 @@
default = Label("//tools/build/bazel:pom_generator"),
),
},
- implementation = _impl,
+ implementation = _impl_pom_file,
+ outputs = {"pom": "%{name}.pom"},
+)
+
+def _impl_dependencies_pom(ctx):
+ arguments = [
+ "-o",
+ ctx.outputs.pom.path,
+ "-p",
+ ctx.file.pom_template.path,
+ "-d",
+ ] + [maven_coordinates(d.label) for d in ctx.attr.deps] + [
+ "-c",
+ ] + [maven_coordinates(d.label) for d in ctx.attr.deps_provided] + [
+ "-t",
+ ] + [maven_coordinates(d.label) for d in ctx.attr.deps_test] + [
+ "-v",
+ ] + ctx.attr.vars
+
+ ctx.actions.run(
+ inputs = [ctx.file.pom_template],
+ outputs = [ctx.outputs.pom],
+ progress_message = "Generating dependencies pom for %s" % ctx.attr.name,
+ arguments = arguments,
+ executable = ctx.executable._pom_generator,
+ )
+
+dependencies_pom = rule(
+ attrs = {
+ "pom_template": attr.label(allow_single_file = True),
+ "deps_provided": attr.label_list(),
+ "deps_test": attr.label_list(),
+ "deps": attr.label_list(),
+ "vars": attr.string_list(),
+ "_pom_generator": attr.label(
+ executable = True,
+ cfg = "host",
+ allow_files = True,
+ default = Label("//tools/build/bazel:dependencies_pom_generator"),
+ ),
+ },
+ implementation = _impl_dependencies_pom,
outputs = {"pom": "%{name}.pom"},
)
diff --git a/tools/build/bazel/variables.bzl b/tools/build/bazel/variables.bzl
index c0b2e69..121a529 100644
--- a/tools/build/bazel/variables.bzl
+++ b/tools/build/bazel/variables.bzl
@@ -4,3 +4,4 @@
ONOS_ORIGIN = "ONOS Community"
APP_PREFIX = ONOS_GROUP_ID + "."
DEFAULT_APP_CATEGORY = "Utility"
+DEFAULT_JAVA_VERSION = "11"
diff --git a/tools/build/conf/BUILD b/tools/build/conf/BUILD
index 1eb4fae..bf1effb 100644
--- a/tools/build/conf/BUILD
+++ b/tools/build/conf/BUILD
@@ -1,3 +1,5 @@
+load("//tools/build/bazel:pom_file.bzl", "pom_file")
+
checkstyle_source = "src/main/resources/onos/checkstyle.xml"
suppression_source = "src/main/resources/onos/suppressions.xml"
@@ -27,3 +29,9 @@
resources = glob(["src/main/resources/onos/**"]),
visibility = ["//visibility:public"],
)
+
+pom_file(
+ name = "onos-build-conf-pom",
+ artifact = "onos-build-conf",
+ visibility = ["//visibility:public"],
+)
diff --git a/tools/build/conf/src/main/java/org/onosproject/checkstyle/CheckstyleRunner.java b/tools/build/conf/src/main/java/org/onosproject/checkstyle/CheckstyleRunner.java
deleted file mode 100644
index ab1f7eb..0000000
--- a/tools/build/conf/src/main/java/org/onosproject/checkstyle/CheckstyleRunner.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.checkstyle;
-
-import com.puppycrawl.tools.checkstyle.Checker;
-import com.puppycrawl.tools.checkstyle.ConfigurationLoader;
-import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
-import com.puppycrawl.tools.checkstyle.PropertiesExpander;
-import com.puppycrawl.tools.checkstyle.api.AuditEvent;
-import com.puppycrawl.tools.checkstyle.api.AuditListener;
-import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
-import com.puppycrawl.tools.checkstyle.api.Configuration;
-import org.onosproject.buckdaemon.BuckTask;
-import org.onosproject.buckdaemon.BuckTaskContext;
-
-import java.io.File;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.stream.Collectors;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-
-/**
- * Buck task for executing checkstyle on the specified project files.
- */
-public class CheckstyleRunner implements BuckTask {
-
- private final Configuration config;
-
- public CheckstyleRunner(String configLocation, String suppressionLocation) {
- try {
- // create a configuration
- DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader
- .loadConfiguration(configLocation, new PropertiesExpander(System.getProperties()));
-
- // add the suppression file to the configuration
- DefaultConfiguration suppressions = new DefaultConfiguration("SuppressionFilter");
- suppressions.addAttribute("file", suppressionLocation);
- config.addChild(suppressions);
-
- this.config = config;
- } catch (CheckstyleException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public void execute(BuckTaskContext context) {
- List<String> input = context.input();
- if (input.size() < 3 || input.get(2).length() == 0) {
- return;
- }
- String project = input.get(0);
- String baseDir = input.get(1);
-
- // create a listener for output
- StringAuditor listener = new StringAuditor(context);
- listener.setProjectName(project);
- listener.setBaseDir(baseDir);
-
- // create Checker object and run it
- final Checker checker = new Checker();
- final ClassLoader moduleClassLoader = Checker.class.getClassLoader();
- checker.setModuleClassLoader(moduleClassLoader);
-
- try {
- checker.configure(config);
- checker.addListener(listener);
-
- // run Checker
- List<File> fileList = input.subList(2, input.size()).stream()
- .filter(s -> !s.contains("/:")) // Yes, fighting a hack with a hack.
- .map(File::new)
- .collect(Collectors.toList());
- int errorCounter = checker.process(fileList);
- if (errorCounter > 0) {
- context.output("CHECKSTYLE ERROR");
- }
-
- listener.await();
- } catch (CheckstyleException | InterruptedException e) {
- e.printStackTrace(); //dump exeception to stderr
- throw new RuntimeException(e);
- } finally {
- checker.destroy();
- }
-
- }
-
- static class StringAuditor implements AuditListener {
-
- private final BuckTaskContext context;
- private CountDownLatch finishedLatch = new CountDownLatch(1);
- private String baseDir = "";
- private String project = "";
-
- StringAuditor(BuckTaskContext context) {
- this.context = context;
- }
-
- public void setBaseDir(String base) {
- this.baseDir = base;
- }
-
- public void setProjectName(String projectName) {
- this.project = projectName;
- }
-
- public void await() throws InterruptedException {
- finishedLatch.await();
- }
-
- @Override
- public void auditStarted(AuditEvent evt) {
- }
-
- @Override
- public void auditFinished(AuditEvent evt) {
- finishedLatch.countDown();
- }
-
- @Override
- public void fileStarted(AuditEvent evt) {
- }
-
- @Override
- public void fileFinished(AuditEvent evt) {
- }
-
- @Override
- public void addError(AuditEvent evt) {
- switch (evt.getSeverityLevel()) {
- case ERROR:
- StringBuilder output = new StringBuilder();
- String fileName = evt.getFileName();
- if (!isNullOrEmpty(baseDir)) {
- int index = fileName.indexOf(baseDir);
- if (index >= 0) {
- fileName = fileName.substring(index + baseDir.length() + 1);
- if (!isNullOrEmpty(project)) {
- output.append(project).append(':');
- }
- }
- }
- output.append(fileName).append(':').append(evt.getLine());
- if (evt.getColumn() > 0) {
- output.append(':').append(evt.getColumn());
- }
- output.append(": ").append(evt.getMessage());
- context.output(output.toString());
- break;
- case IGNORE:
- case INFO:
- case WARNING:
- default:
- break;
- }
- }
-
- @Override
- public void addException(AuditEvent evt, Throwable throwable) {
- addError(evt);
- context.output(throwable.getMessage());
- }
- }
-
-}
diff --git a/tools/build/conf/src/main/java/org/onosproject/checkstyle/package-info.java b/tools/build/conf/src/main/java/org/onosproject/checkstyle/package-info.java
deleted file mode 100644
index 241a819..0000000
--- a/tools/build/conf/src/main/java/org/onosproject/checkstyle/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * checkstyle runner for BuckDaemon.
- */
-package org.onosproject.checkstyle;
diff --git a/tools/build/conf/src/main/resources/onos/checkstyle-mvn.xml b/tools/build/conf/src/main/resources/onos/checkstyle-mvn.xml
index a236f73..fcad23f 100644
--- a/tools/build/conf/src/main/resources/onos/checkstyle-mvn.xml
+++ b/tools/build/conf/src/main/resources/onos/checkstyle-mvn.xml
@@ -115,6 +115,14 @@
<property name="message" value="javafx classes are not supported by all JDKs."/>
</module>
+ <!-- Don't allow usage of RuntimeException -->
+ <module name="RegexpSingleline">
+ <property name="format" value="throw[ ]*new[ ]*RuntimeException"/>
+ <property name="minimum" value="0"/>
+ <property name="maximum" value="0"/>
+ <property name="message" value="Don't throw generic exception types"/>
+ </module>
+
<!-- Checks for Headers -->
<!-- See http://checkstyle.sf.net/config_header.html -->
<!-- <module name="Header"> -->
@@ -122,12 +130,6 @@
<!-- <property name="fileExtensions" value="java"/> -->
<!-- </module> -->
- <module name="RegexpHeader">
- <!-- The following line is different for maven due to how the maven checkstyle plugin works -->
- <property name="headerFile" value="${checkstyle.header.file}"/>
- <property name="fileExtensions" value="java"/>
- </module>
-
<module name="SuppressWarningsFilter" />
<module name="SuppressWithPlainTextCommentFilter"/>
@@ -164,13 +166,13 @@
<property name="suppressLoadErrors" value="true"/>
</module>
<module name="JavadocType">
- <property name="severity" value="warning"/>
+ <property name="severity" value="ignore"/>
</module>
<module name="JavadocVariable">
<!-- Suppress check for private member Javadocs.
Possibly revist fixing these. -->
<property name="scope" value="public"/>
- <property name="severity" value="warning"/>
+ <property name="severity" value="ignore"/>
</module>
<module name="JavadocStyle"/>
<!-- @author tag should not be used -->
@@ -309,7 +311,7 @@
<module name="InterfaceIsType"/>
<module name="VisibilityModifier">
- <property name="severity" value="warning"/>
+ <property name="severity" value="ignore"/>
</module>
diff --git a/tools/build/conf/src/main/resources/onos/pmd.xml b/tools/build/conf/src/main/resources/onos/pmd.xml
index 156e6f9..19bac09 100644
--- a/tools/build/conf/src/main/resources/onos/pmd.xml
+++ b/tools/build/conf/src/main/resources/onos/pmd.xml
@@ -15,63 +15,59 @@
~ limitations under the License.
-->
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- name="ONOS Rules"
- xmlns="http://pmd.sf.net/ruleset/1.0.0"
- xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
- xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" >
+ name="ONOS Rules"
+ xmlns="http://pmd.sf.net/ruleset/1.0.0"
+ xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
+ xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>ONOS PMD rules</description>
- <rule ref="rulesets/java/unnecessary.xml" >
- <exclude name="UselessParentheses" />
+
+ <rule ref="category/java/errorprone.xml">
+ <exclude name="EmptyCatchBlock"/>
</rule>
- <rule ref="rulesets/java/basic.xml">
- <exclude name="EmptyCatchBlock"/>
+ <rule ref="category/java/errorprone.xml/EmptyCatchBlock">
+ <properties>
+ <property name="allowCommentedBlocks" value="true"/>
+ </properties>
</rule>
- <rule ref="rulesets/java/basic.xml/EmptyCatchBlock">
- <properties>
- <property name="allowCommentedBlocks" value="true"/>
- </properties>
- </rule>
- <rule ref="rulesets/java/unusedcode.xml">
- <!-- Explicit public keyword in interface methods is acceptable -->
- <exclude name="UnusedModifier" />
- </rule>
- <rule ref="rulesets/java/imports.xml"/>
+ <rule ref="category/java/bestpractices.xml"/>
<rule ref="rulesets/java/optimizations.xml">
- <exclude name="LocalVariableCouldBeFinal" />
- <exclude name="MethodArgumentCouldBeFinal" />
- <exclude name="AvoidInstantiatingObjectsInLoops" />
+ <exclude name="AvoidInstantiatingObjectsInLoops"/>
</rule>
<rule ref="rulesets/java/strings.xml">
- <exclude name="AvoidDuplicateLiterals" />
+ <exclude name="AvoidDuplicateLiterals"/>
</rule>
<rule ref="rulesets/java/braces.xml"/>
- <rule ref="rulesets/java/naming.xml">
- <exclude name="AvoidInstantiatingObjectsInLoops" />
- <exclude name="ShortClassName" />
- <exclude name="ShortMethodName" />
- <exclude name="ShortVariable" />
- <exclude name="LongVariable" />
+ <rule ref="category/java/codestyle.xml">
+ <!-- Explicit public keyword in interface methods is acceptable -->
+ <exclude name="UnnecessaryModifier"/>
+ <exclude name="UselessParentheses"/>
+ <exclude name="ShortClassName"/>
+ <exclude name="ShortMethodName"/>
+ <exclude name="ShortVariable"/>
+ <exclude name="LongVariable"/>
+ <exclude name="MethodArgumentCouldBeFinal"/>
+ <exclude name="LocalVariableCouldBeFinal"/>
</rule>
- <rule ref="rulesets/java/naming.xml/VariableNamingConventions">
- <properties>
- <!-- ONOS allows the name "log" for static final Loggers -->
- <property name="violationSuppressRegex" value=".*'log'.*"/>
- </properties>
+ <rule ref="category/java/codestyle.xml/VariableNamingConventions">
+ <properties>
+ <!-- ONOS allows the name "log" for static final Loggers -->
+ <property name="violationSuppressRegex" value=".*'log'.*"/>
+ </properties>
</rule>
<rule ref="rulesets/java/clone.xml"/>
<rule ref="rulesets/java/strictexception.xml"/>
<rule ref="rulesets/java/design.xml">
- <exclude name="GodClass" />
+ <exclude name="GodClass"/>
</rule>
<rule ref="rulesets/java/coupling.xml">
- <exclude name="LawOfDemeter" />
- <exclude name="ExcessiveImports" />
- <!-- Suppress Removed misconfigured rule warning -->
- <exclude name="LoosePackageCoupling" />
+ <exclude name="LawOfDemeter"/>
+ <exclude name="ExcessiveImports"/>
+ <!-- Suppress Removed misconfigured rule warning -->
+ <exclude name="LoosePackageCoupling"/>
</rule>
</ruleset>
diff --git a/tools/build/conf/src/main/resources/onos/suppressions.xml b/tools/build/conf/src/main/resources/onos/suppressions.xml
index c4e43e2..9f433a7 100644
--- a/tools/build/conf/src/main/resources/onos/suppressions.xml
+++ b/tools/build/conf/src/main/resources/onos/suppressions.xml
@@ -61,4 +61,6 @@
<!-- Suppressions for yangutils generated code -->
<suppress files="org.onosproject.yang.gen.v1.*" checks="Javadoc.*" />
+
+ <suppress files="ApiDocRegistrator.java" checks="JavadocPackage" />
</suppressions>
diff --git a/tools/build/jdk/BUILD b/tools/build/jdk/BUILD
index 59934fc..0055031 100644
--- a/tools/build/jdk/BUILD
+++ b/tools/build/jdk/BUILD
@@ -3,12 +3,13 @@
# :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 = "11",
- target_version = "11",
+ source_version = DEFAULT_JAVA_VERSION,
+ target_version = DEFAULT_JAVA_VERSION,
visibility = ["//visibility:public"],
)
diff --git a/tools/build/onos-change-version b/tools/build/onos-change-version
index f9ea36d..a0dad83 100755
--- a/tools/build/onos-change-version
+++ b/tools/build/onos-change-version
@@ -28,8 +28,8 @@
# Augment the version in archetypes tree.
mvn -q -B -f tools/package/archetypes/pom.xml versions:set -DnewVersion=$NEW_VERSION versions:commit
for atype in api bundle cli rest ui ui2 uitab uitopo; do
- pom="tools/package/archetypes/$atype/src/main/resources/archetype-resources/pom.xml"
- sed -i".VERBACK" -E "1,/<onos.version>/s/<onos.version>[^<]*</<onos.version>$NEW_VERSION</g" $pom
+ meta="tools/package/archetypes/$atype/src/main/resources/META-INF/maven/archetype-metadata.xml"
+ sed -i".VERBACK" -E "1,/<defaultValue>/s/<defaultValue>[^<]*</<defaultValue>$NEW_VERSION</g" $meta
done
sed -i".VERBACK" -E "s/-DarchetypeVersion=[^\"]*/-DarchetypeVersion=$NEW_VERSION/g" $ONOS_ROOT/tools/test/bin/onos-archetypes-test
diff --git a/tools/build/onos-publish-catalog b/tools/build/onos-publish-catalog
index cd2015b..595c74e 100755
--- a/tools/build/onos-publish-catalog
+++ b/tools/build/onos-publish-catalog
@@ -35,11 +35,15 @@
}
function jars {
- egrep -v '(\#|build/conf)' tools/build/publish-target-list
+ egrep -v '(\#)' tools/build/publish-target-list
}
function testJars {
- egrep -v '(\#|build/conf)' tools/build/publish-test-target-list
+ egrep -v '(\#)' tools/build/publish-test-target-list
+}
+
+function sources {
+ egrep -v '(\#|build/conf|dependencies)' tools/build/publish-target-list
}
echo "Cataloging jar files..."
@@ -54,9 +58,9 @@
[ $libsOnly = true ] && exit 0
echo "Cataloging source jars..."
-writeCatalog $(jars | sed 's/$/-sources/')
+writeCatalog $(sources | sed 's/$/-sources/')
echo "Cataloging javadoc jars..."
-writeCatalog $(jars | sed 's/$/-javadoc/')
+writeCatalog $(sources | sed 's/$/-javadoc/')
echo "Cataloging oar files..."
writeCatalog $(bazel query 'kind("_onos_oar rule", //...)')
diff --git a/tools/build/publish-target-list b/tools/build/publish-target-list
index 7d9a87b..bc769ee 100644
--- a/tools/build/publish-target-list
+++ b/tools/build/publish-target-list
@@ -44,6 +44,7 @@
//protocols/restconf/client/api:onos-protocols-restconf-client-api
//protocols/snmp/api:onos-protocols-snmp-api
//tools/build/conf:onos-build-conf
+ //tools/package/dependencies:onos-dependencies
//utils/junit:onlab-junit
//utils/misc:onlab-misc
//utils/osgi:onlab-osgi