Brian O'Connor

Updating checkstyle rule in onos.bucklet

Change-Id: I16422bf02b55572d82d9463cb87c678545b79793
......@@ -68,7 +68,7 @@ def osgi_jar(
**kwargs
)
cp = ':'.join(['$(classpath %s)' % c for c in deps])
cp = ':'.join(['$(classpath %s)' % c for c in deps]) if deps else '""'
args = ( '$(location :%s)' % bare_jar_name, #input jar
'$OUT', #output jar
......@@ -111,6 +111,8 @@ def osgi_jar(
### Checkstyle
if srcs:
chk_cmd = '#!/bin/sh\n'
# FIXME hack to add dependency on suppressions-xml in the checkstyle rule
chk_cmd += 'FOO="$(location //tools/build/conf:suppressions-xml)"\n'
base = get_base_path()
chk_cmd += ' '.join(( 'java -jar $(location //lib:checkstyle)',
'-c $(location //tools/build/conf:checkstyle-xml)',
......@@ -118,6 +120,7 @@ def osgi_jar(
chk_cmd += ' | grep -E "^[^: ]*:\d+:\d+: error:"'
chk_cmd += ' | sed "s#^.*%s/#%s:#g"\n' % (base, name)
chk_cmd += 'test ${PIPESTATUS[0]} -eq 0\n' # status of java command
genrule(
name = name + '-checkstyle-sh',
bash = "echo '%s' > $OUT && chmod +x $OUT" % chk_cmd,
......
......@@ -2,7 +2,7 @@ checkstyle_source = 'src/main/resources/onos/checkstyle.xml'
suppression_source = 'src/main/resources/onos/suppressions.xml'
xml = ('<module name="SuppressionFilter">'
'<property name="file" value="$(location :suppressions.xml)"/>'
'<property name="file" value="$(location :suppressions-xml)"/>'
'</module>' )
cmd = "sed 's#<module name=\"Checker\">#<module name=\"Checker\">%s#' %s > $OUT" % ( xml, checkstyle_source )
......@@ -16,6 +16,7 @@ genrule(
#FIXME location suppression.xml does not trigger this rule
export_file(
name = 'suppressions.xml',
name = 'suppressions-xml',
src = suppression_source,
visibility = [ 'PUBLIC' ]
)
......