sources = glob(['**/*.java']) dependencies = [ '//infer/annotations:annotations', ] java_library( name = 'tracing', srcs = sources, deps = dependencies, visibility = [ 'PUBLIC' ] ) out = 'out' clean_cmd = ' '.join(['rm', '-rf', out]) classpath = ':'.join([('$(classpath ' + path + ')') for path in dependencies]) infer_cmd = ' '.join([ 'infer', '--no-progress-bar', '--absolute-paths', '-o', out, '-a', 'tracing', '--', 'javac', '-cp', classpath, '$SRCS', ]) copy_cmd = ' '.join(['cp', out + '/report.csv', '$OUT']) command = ' && '.join([clean_cmd, infer_cmd, copy_cmd]) genrule( name = 'analyze', srcs = sources, out = 'report.csv', cmd = command, deps = dependencies + [':tracing'], visibility = [ 'PUBLIC', ] )