Moving checkstyle run to buck test
Change-Id: Ib8d2e2fbb71585d90ac5df44d08a186f22fe0425
Showing
1 changed file
with
25 additions
and
12 deletions
... | @@ -91,8 +91,6 @@ def osgi_jar( | ... | @@ -91,8 +91,6 @@ def osgi_jar( |
91 | if debug: | 91 | if debug: |
92 | bash = stage_jar + DEBUG_ARG + ' ' + wrap_jar | 92 | bash = stage_jar + DEBUG_ARG + ' ' + wrap_jar |
93 | print bash | 93 | print bash |
94 | - # TODO this is a hack to add checkstyle as dependency before generating jar | ||
95 | - bash = 'ls $(location :' + name + '-checkstyle) > /dev/null; ' + bash | ||
96 | 94 | ||
97 | genrule( | 95 | genrule( |
98 | name = osgi_jar_name, | 96 | name = osgi_jar_name, |
... | @@ -111,21 +109,36 @@ def osgi_jar( | ... | @@ -111,21 +109,36 @@ def osgi_jar( |
111 | ) | 109 | ) |
112 | 110 | ||
113 | ### Checkstyle | 111 | ### Checkstyle |
114 | - chk_cmd = ' '.join(( 'java -jar $(location //lib:checkstyle)', | 112 | + chk_cmd = '#!/bin/sh\n' |
115 | - '-o $OUT', | 113 | + base = get_base_path() |
114 | + chk_cmd += ' '.join(( 'java -jar $(location //lib:checkstyle)', | ||
116 | '-c $(location //tools/build/conf:checkstyle-xml)', | 115 | '-c $(location //tools/build/conf:checkstyle-xml)', |
117 | - ' '.join(srcs) )) | 116 | + ' '.join(['%s/%s' % (base, s) for s in srcs]) )) |
118 | - error_cmd = ' | '.join(( '( touch $OUT; cat $OUT', | 117 | + chk_cmd += ' | grep -E "^[^: ]*:\d+:\d+: error:"' |
119 | - 'grep -E "^[^: ]*:\d+:\d+: error:"', | 118 | + chk_cmd += ' | sed "s#^.*%s/#%s:#g"\n' % (base, name) |
120 | - 'sed "s#^.*__srcs/#%s:#g" ; exit 1)' % name, )) | 119 | + chk_cmd += 'test ${PIPESTATUS[0]} -eq 0\n' # status of java command |
121 | - cmd = ' || '.join((chk_cmd, error_cmd)) | ||
122 | genrule( | 120 | genrule( |
123 | - name = name + '-checkstyle', | 121 | + name = name + '-checkstyle-sh', |
124 | - bash = cmd, | 122 | + bash = "echo '%s' > $OUT && chmod +x $OUT" % chk_cmd, |
125 | srcs = srcs, | 123 | srcs = srcs, |
126 | - out = 'checkstyle.log', | 124 | + out = 'checkstyle.sh', |
125 | + ) | ||
126 | + | ||
127 | + sh_test( | ||
128 | + name = name + '-checkstyle', | ||
129 | + test = ':' + name + '-checkstyle-sh', | ||
130 | + deps = [ ':'+ bare_jar_name ], | ||
131 | + labels = [ 'checkstyle' ], | ||
127 | ) | 132 | ) |
128 | 133 | ||
134 | + # TODO add project config for intellij | ||
135 | + # project_config( | ||
136 | + # src_target = ':' + bare_jar_name, | ||
137 | + # src_roots = [ 'src/main/java' ], | ||
138 | + # test_target = ':' + name + '-tests', | ||
139 | + # test_roots = [ 'src/test/java' ], | ||
140 | + # ) | ||
141 | + | ||
129 | ### .m2 Install | 142 | ### .m2 Install |
130 | mvn_cmd = ' '.join(( 'mvn install:install-file', | 143 | mvn_cmd = ' '.join(( 'mvn install:install-file', |
131 | '-Dfile=$(location :%s)' % name, | 144 | '-Dfile=$(location :%s)' % name, | ... | ... |
-
Please register or login to post a comment