Brian O'Connor

Updating checkstyle rule in onos.bucklet

Change-Id: I16422bf02b55572d82d9463cb87c678545b79793
...@@ -68,7 +68,7 @@ def osgi_jar( ...@@ -68,7 +68,7 @@ def osgi_jar(
68 **kwargs 68 **kwargs
69 ) 69 )
70 70
71 - cp = ':'.join(['$(classpath %s)' % c for c in deps]) 71 + cp = ':'.join(['$(classpath %s)' % c for c in deps]) if deps else '""'
72 72
73 args = ( '$(location :%s)' % bare_jar_name, #input jar 73 args = ( '$(location :%s)' % bare_jar_name, #input jar
74 '$OUT', #output jar 74 '$OUT', #output jar
...@@ -110,29 +110,32 @@ def osgi_jar( ...@@ -110,29 +110,32 @@ def osgi_jar(
110 110
111 ### Checkstyle 111 ### Checkstyle
112 if srcs: 112 if srcs:
113 - chk_cmd = '#!/bin/sh\n' 113 + chk_cmd = '#!/bin/sh\n'
114 - base = get_base_path() 114 + # FIXME hack to add dependency on suppressions-xml in the checkstyle rule
115 - chk_cmd += ' '.join(( 'java -jar $(location //lib:checkstyle)', 115 + chk_cmd += 'FOO="$(location //tools/build/conf:suppressions-xml)"\n'
116 - '-c $(location //tools/build/conf:checkstyle-xml)', 116 + base = get_base_path()
117 - ' '.join(['%s/%s' % (base, s) for s in srcs]) )) 117 + chk_cmd += ' '.join(( 'java -jar $(location //lib:checkstyle)',
118 - chk_cmd += ' | grep -E "^[^: ]*:\d+:\d+: error:"' 118 + '-c $(location //tools/build/conf:checkstyle-xml)',
119 - chk_cmd += ' | sed "s#^.*%s/#%s:#g"\n' % (base, name) 119 + ' '.join(['%s/%s' % (base, s) for s in srcs]) ))
120 - chk_cmd += 'test ${PIPESTATUS[0]} -eq 0\n' # status of java command 120 + chk_cmd += ' | grep -E "^[^: ]*:\d+:\d+: error:"'
121 - genrule( 121 + chk_cmd += ' | sed "s#^.*%s/#%s:#g"\n' % (base, name)
122 - name = name + '-checkstyle-sh', 122 + chk_cmd += 'test ${PIPESTATUS[0]} -eq 0\n' # status of java command
123 - bash = "echo '%s' > $OUT && chmod +x $OUT" % chk_cmd, 123 +
124 - srcs = srcs, 124 + genrule(
125 - out = 'checkstyle.sh', 125 + name = name + '-checkstyle-sh',
126 - ) 126 + bash = "echo '%s' > $OUT && chmod +x $OUT" % chk_cmd,
127 - 127 + srcs = srcs,
128 - sh_test( 128 + out = 'checkstyle.sh',
129 - name = name + '-checkstyle', 129 + )
130 - test = ':' + name + '-checkstyle-sh', 130 +
131 - deps = [ ':'+ bare_jar_name ], 131 + sh_test(
132 - labels = [ 'checkstyle' ], 132 + name = name + '-checkstyle',
133 - ) 133 + test = ':' + name + '-checkstyle-sh',
134 + deps = [ ':'+ bare_jar_name ],
135 + labels = [ 'checkstyle' ],
136 + )
134 else: 137 else:
135 - print 'Not generating checkstyle rule for %s because there are no sources.' % name 138 + print 'Not generating checkstyle rule for %s because there are no sources.' % name
136 139
137 # TODO add project config for intellij 140 # TODO add project config for intellij
138 # project_config( 141 # project_config(
......
...@@ -2,7 +2,7 @@ checkstyle_source = 'src/main/resources/onos/checkstyle.xml' ...@@ -2,7 +2,7 @@ checkstyle_source = 'src/main/resources/onos/checkstyle.xml'
2 suppression_source = 'src/main/resources/onos/suppressions.xml' 2 suppression_source = 'src/main/resources/onos/suppressions.xml'
3 3
4 xml = ('<module name="SuppressionFilter">' 4 xml = ('<module name="SuppressionFilter">'
5 - '<property name="file" value="$(location :suppressions.xml)"/>' 5 + '<property name="file" value="$(location :suppressions-xml)"/>'
6 '</module>' ) 6 '</module>' )
7 cmd = "sed 's#<module name=\"Checker\">#<module name=\"Checker\">%s#' %s > $OUT" % ( xml, checkstyle_source ) 7 cmd = "sed 's#<module name=\"Checker\">#<module name=\"Checker\">%s#' %s > $OUT" % ( xml, checkstyle_source )
8 8
...@@ -16,6 +16,7 @@ genrule( ...@@ -16,6 +16,7 @@ genrule(
16 16
17 #FIXME location suppression.xml does not trigger this rule 17 #FIXME location suppression.xml does not trigger this rule
18 export_file( 18 export_file(
19 - name = 'suppressions.xml', 19 + name = 'suppressions-xml',
20 src = suppression_source, 20 src = suppression_source,
21 + visibility = [ 'PUBLIC' ]
21 ) 22 )
......