sources = glob([ '**/*.java']) java_library( name = 'file_unchanged', srcs = sources, visibility = [ 'PUBLIC' ] ) out = 'out' clean_cmd = ' '.join(['rm', '-rf', out]) infer_cmd = ' '.join([ 'infer', '--no-progress-bar', '-i', '--absolute-paths', '-o', out, '-a', 'infer', '--', 'javac', '$SRCS', ]) stats_copy_cmd = ' '.join(['cp', out + '/stats.json', '$OUT']) command = ' && '.join([clean_cmd, infer_cmd, infer_cmd, stats_copy_cmd]) genrule( name = 'analyze', srcs = sources, out = 'stats.json', cmd = command, deps = [':file_unchanged'], visibility = [ 'PUBLIC', ] )