mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-18 10:51:04 +02:00
Generate a test rule to run checkstyle for an onos jar file
Change-Id: I21da8d353d592de847cc019875baa59786500cfe
This commit is contained in:
parent
d1ce10ad9e
commit
b7949e7a98
11
lib/BUCK
11
lib/BUCK
@ -1,4 +1,4 @@
|
|||||||
# ***** This file was auto-generated at Wed, 13 Jun 2018 22:38:24 GMT. Do not edit this file manually. *****
|
# ***** This file was auto-generated at Tue, 19 Jun 2018 22:30:22 GMT. Do not edit this file manually. *****
|
||||||
# ***** Use onos-lib-gen *****
|
# ***** Use onos-lib-gen *****
|
||||||
|
|
||||||
pass_thru_pom(
|
pass_thru_pom(
|
||||||
@ -223,6 +223,15 @@ remote_jar (
|
|||||||
visibility = [ 'PUBLIC' ],
|
visibility = [ 'PUBLIC' ],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
remote_jar (
|
||||||
|
name = 'commons-cli',
|
||||||
|
out = 'commons-cli-1.3.jar',
|
||||||
|
url = 'mvn:commons-cli:commons-cli:jar:1.3',
|
||||||
|
sha1 = 'a48653b6bcd06b5e61ed63739ca601701fcb6a6c',
|
||||||
|
maven_coords = 'commons-cli:commons-cli:1.3',
|
||||||
|
visibility = [ 'PUBLIC' ],
|
||||||
|
)
|
||||||
|
|
||||||
remote_jar (
|
remote_jar (
|
||||||
name = 'commons-collections',
|
name = 'commons-collections',
|
||||||
out = 'commons-collections-3.2.2.jar',
|
out = 'commons-collections-3.2.2.jar',
|
||||||
|
@ -118,6 +118,7 @@
|
|||||||
"asm": "mvn:org.ow2.asm:asm:5.0.4",
|
"asm": "mvn:org.ow2.asm:asm:5.0.4",
|
||||||
"atomix": "mvn:io.atomix:atomix:2.0.22",
|
"atomix": "mvn:io.atomix:atomix:2.0.22",
|
||||||
"commons-codec": "mvn:commons-codec:commons-codec:1.10",
|
"commons-codec": "mvn:commons-codec:commons-codec:1.10",
|
||||||
|
"commons-cli": "mvn:commons-cli:commons-cli:1.3",
|
||||||
"commons-collections": "mvn:commons-collections:commons-collections:3.2.2",
|
"commons-collections": "mvn:commons-collections:commons-collections:3.2.2",
|
||||||
"commons-configuration": "mvn:commons-configuration:commons-configuration:1.10",
|
"commons-configuration": "mvn:commons-configuration:commons-configuration:1.10",
|
||||||
"commons-io": "mvn:commons-io:commons-io:2.6",
|
"commons-io": "mvn:commons-io:commons-io:2.6",
|
||||||
|
85
tools/build/bazel/checkstyle.bzl
Normal file
85
tools/build/bazel/checkstyle.bzl
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
"""
|
||||||
|
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.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Implementation of the rule to call checkstyle
|
||||||
|
"""
|
||||||
|
def _checkstyle_impl(ctx):
|
||||||
|
classpath = ""
|
||||||
|
need_colon = False
|
||||||
|
for file in ctx.files._classpath:
|
||||||
|
if need_colon:
|
||||||
|
classpath += ":"
|
||||||
|
need_colon = True
|
||||||
|
classpath += file.path
|
||||||
|
|
||||||
|
cmd = " ".join(
|
||||||
|
["java -cp %s com.puppycrawl.tools.checkstyle.Main" % classpath] +
|
||||||
|
["-c %s" % ctx.attr._config.files.to_list()[0].path] +
|
||||||
|
[src_file.path for src_file in ctx.files.srcs])
|
||||||
|
|
||||||
|
ctx.actions.write(
|
||||||
|
output = ctx.outputs.executable,
|
||||||
|
content = cmd,
|
||||||
|
)
|
||||||
|
|
||||||
|
inputs = (ctx.files.srcs +
|
||||||
|
ctx.files._classpath +
|
||||||
|
ctx.attr._config.files.to_list() +
|
||||||
|
ctx.attr._suppressions.files.to_list() +
|
||||||
|
ctx.attr._java_header.files.to_list())
|
||||||
|
|
||||||
|
runfiles = ctx.runfiles(files = inputs)
|
||||||
|
return [DefaultInfo(runfiles = runfiles)]
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Rule definition for calling checkstyle
|
||||||
|
"""
|
||||||
|
_execute_checkstyle_test = rule(
|
||||||
|
test = True,
|
||||||
|
attrs = {
|
||||||
|
"_classpath": attr.label_list(default=[
|
||||||
|
Label("@checkstyle//jar"),
|
||||||
|
Label("@commons_beanutils//jar"),
|
||||||
|
Label("@commons_cli//jar"),
|
||||||
|
Label("@commons_collections//jar"),
|
||||||
|
Label("@antlr//jar"),
|
||||||
|
Label("@guava//jar"),
|
||||||
|
Label("@commons_logging//jar"),
|
||||||
|
]),
|
||||||
|
"srcs": attr.label_list(allow_files = FileType([".java"])),
|
||||||
|
"_config": attr.label(default=Label("//tools/build/conf:checkstyle_xml")),
|
||||||
|
"_suppressions": attr.label(default=Label("//tools/build/conf:suppressions_xml")),
|
||||||
|
"_java_header": attr.label(default=Label("//tools/build/conf:onos_java_header")),
|
||||||
|
},
|
||||||
|
|
||||||
|
implementation = _checkstyle_impl,
|
||||||
|
)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Macro to instantiate the checkstyle rule for a given set of sources.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
name: name of the target to generate. Required.
|
||||||
|
srcs: list of source file targets to run checkstyle on. Required.
|
||||||
|
size: test size constraint. Optional, defaults to "small"
|
||||||
|
"""
|
||||||
|
def checkstyle_test(name, srcs):
|
||||||
|
_execute_checkstyle_test(name = name, srcs = srcs, size = "small")
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
# ***** This file was auto-generated at Wed, 13 Jun 2018 22:38:28 GMT. Do not edit this file manually. *****
|
# ***** This file was auto-generated at Tue, 19 Jun 2018 22:30:34 GMT. Do not edit this file manually. *****
|
||||||
# ***** Use onos-lib-gen *****
|
# ***** Use onos-lib-gen *****
|
||||||
|
|
||||||
load("//tools/build/bazel:variables.bzl", "ONOS_GROUP_ID", "ONOS_VERSION")
|
load("//tools/build/bazel:variables.bzl", "ONOS_GROUP_ID", "ONOS_VERSION")
|
||||||
@ -142,6 +142,12 @@ def generated_maven_jars():
|
|||||||
sha1 = "4b95f4897fa13f2cd904aee711aeafc0c5295cd8",
|
sha1 = "4b95f4897fa13f2cd904aee711aeafc0c5295cd8",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
native.maven_jar(
|
||||||
|
name = "commons_cli",
|
||||||
|
artifact = "commons-cli:commons-cli:1.3",
|
||||||
|
sha1 = "a48653b6bcd06b5e61ed63739ca601701fcb6a6c",
|
||||||
|
)
|
||||||
|
|
||||||
native.maven_jar(
|
native.maven_jar(
|
||||||
name = "commons_collections",
|
name = "commons_collections",
|
||||||
artifact = "commons-collections:commons-collections:3.2.2",
|
artifact = "commons-collections:commons-collections:3.2.2",
|
||||||
@ -1140,6 +1146,12 @@ def generated_java_libraries():
|
|||||||
exports = ["@commons_codec//jar"],
|
exports = ["@commons_codec//jar"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
native.java_library(
|
||||||
|
name = "commons_cli",
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
exports = ["@commons_cli//jar"],
|
||||||
|
)
|
||||||
|
|
||||||
native.java_library(
|
native.java_library(
|
||||||
name = "commons_collections",
|
name = "commons_collections",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
@ -2100,6 +2112,7 @@ artifact_map[str(Label("@amqp_client//jar"))] = "mvn:com.rabbitmq:amqp-client:ja
|
|||||||
artifact_map[str(Label("@asm//jar"))] = "mvn:org.ow2.asm:asm:jar:5.0.4"
|
artifact_map[str(Label("@asm//jar"))] = "mvn:org.ow2.asm:asm:jar:5.0.4"
|
||||||
artifact_map[str(Label("@atomix//jar"))] = "mvn:io.atomix:atomix:jar:2.0.22"
|
artifact_map[str(Label("@atomix//jar"))] = "mvn:io.atomix:atomix:jar:2.0.22"
|
||||||
artifact_map[str(Label("@commons_codec//jar"))] = "mvn:commons-codec:commons-codec:jar:1.10"
|
artifact_map[str(Label("@commons_codec//jar"))] = "mvn:commons-codec:commons-codec:jar:1.10"
|
||||||
|
artifact_map[str(Label("@commons_cli//jar"))] = "mvn:commons-cli:commons-cli:jar:1.3"
|
||||||
artifact_map[str(Label("@commons_collections//jar"))] = "mvn:commons-collections:commons-collections:jar:3.2.2"
|
artifact_map[str(Label("@commons_collections//jar"))] = "mvn:commons-collections:commons-collections:jar:3.2.2"
|
||||||
artifact_map[str(Label("@commons_configuration//jar"))] = "mvn:commons-configuration:commons-configuration:jar:1.10"
|
artifact_map[str(Label("@commons_configuration//jar"))] = "mvn:commons-configuration:commons-configuration:jar:1.10"
|
||||||
artifact_map[str(Label("@commons_io//jar"))] = "mvn:commons-io:commons-io:jar:2.6"
|
artifact_map[str(Label("@commons_io//jar"))] = "mvn:commons-io:commons-io:jar:2.6"
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
load("//tools/build/bazel:generate_workspace.bzl", "COMPILE", "TEST")
|
load("//tools/build/bazel:generate_workspace.bzl", "COMPILE", "TEST")
|
||||||
load("//tools/build/bazel:variables.bzl", "ONOS_VERSION")
|
load("//tools/build/bazel:variables.bzl", "ONOS_VERSION")
|
||||||
load("//tools/build/bazel:generate_test_rules.bzl", "generate_test_rules")
|
load("//tools/build/bazel:generate_test_rules.bzl", "generate_test_rules")
|
||||||
|
load("//tools/build/bazel:checkstyle.bzl", "checkstyle_test")
|
||||||
|
|
||||||
def _all_java_sources():
|
def _all_java_sources():
|
||||||
return native.glob(["src/main/java/**/*.java"])
|
return native.glob(["src/main/java/**/*.java"])
|
||||||
@ -451,6 +452,11 @@ def osgi_jar_with_tests(
|
|||||||
deps = all_test_deps,
|
deps = all_test_deps,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
checkstyle_test(
|
||||||
|
name = name + "_checkstyle_test",
|
||||||
|
srcs = srcs,
|
||||||
|
)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Creates an OSGI jar file from a set of source files.
|
Creates an OSGI jar file from a set of source files.
|
||||||
|
|
||||||
|
23
tools/build/conf/BUILD
Normal file
23
tools/build/conf/BUILD
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
checkstyle_source = "src/main/resources/onos/checkstyle.xml"
|
||||||
|
|
||||||
|
suppression_source = "src/main/resources/onos/suppressions.xml"
|
||||||
|
|
||||||
|
header_source = "src/main/resources/onos/onos-java.header"
|
||||||
|
|
||||||
|
filegroup(
|
||||||
|
name = "checkstyle_xml",
|
||||||
|
srcs = [checkstyle_source],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
||||||
|
filegroup(
|
||||||
|
name = "suppressions_xml",
|
||||||
|
srcs = [suppression_source],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
||||||
|
filegroup(
|
||||||
|
name = "onos_java_header",
|
||||||
|
srcs = [header_source],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
@ -122,6 +122,10 @@
|
|||||||
<!-- <property name="fileExtensions" value="java"/> -->
|
<!-- <property name="fileExtensions" value="java"/> -->
|
||||||
<!-- </module> -->
|
<!-- </module> -->
|
||||||
|
|
||||||
|
<module name="SuppressionFilter">
|
||||||
|
<property name="file" value="tools/build/conf/src/main/resources/onos/suppressions.xml"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
<module name="RegexpHeader">
|
<module name="RegexpHeader">
|
||||||
<!-- The following line is different for maven due to how the maven checkstyle plugin works -->
|
<!-- The following line is different for maven due to how the maven checkstyle plugin works -->
|
||||||
<property name="headerFile" value="tools/build/conf/src/main/resources/onos/onos-java.header"/>
|
<property name="headerFile" value="tools/build/conf/src/main/resources/onos/onos-java.header"/>
|
||||||
@ -164,13 +168,13 @@
|
|||||||
<property name="suppressLoadErrors" value="true"/>
|
<property name="suppressLoadErrors" value="true"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="JavadocType">
|
<module name="JavadocType">
|
||||||
<property name="severity" value="warning"/>
|
<property name="severity" value="ignore"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="JavadocVariable">
|
<module name="JavadocVariable">
|
||||||
<!-- Suppress check for private member Javadocs.
|
<!-- Suppress check for private member Javadocs.
|
||||||
Possibly revist fixing these. -->
|
Possibly revist fixing these. -->
|
||||||
<property name="scope" value="public"/>
|
<property name="scope" value="public"/>
|
||||||
<property name="severity" value="warning"/>
|
<property name="severity" value="ignore"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="JavadocStyle"/>
|
<module name="JavadocStyle"/>
|
||||||
<!-- @author tag should not be used -->
|
<!-- @author tag should not be used -->
|
||||||
@ -309,7 +313,7 @@
|
|||||||
<module name="InterfaceIsType"/>
|
<module name="InterfaceIsType"/>
|
||||||
|
|
||||||
<module name="VisibilityModifier">
|
<module name="VisibilityModifier">
|
||||||
<property name="severity" value="warning"/>
|
<property name="severity" value="ignore"/>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user