Skip to content

Commit 7573b40

Browse files
authored
Merge pull request #607 from sourcegraph/bazel-report-semanticdb-errors
If any errors were reported, fail BazelBuildTool with code 1
2 parents a28db33 + 42f8636 commit 7573b40

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

scip-semanticdb/src/main/java/com/sourcegraph/scip_semanticdb/BazelBuildTool.java

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,33 @@ public static int runAndReturnExitCode(String[] args) throws IOException, Interr
3131
}
3232

3333
List<MavenPackage> mavenPackages = mavenPackages(options);
34+
ScipSemanticdbReporter reporter =
35+
new ScipSemanticdbReporter() {
36+
private boolean hasErrors = false;
37+
38+
@Override
39+
public void error(Throwable e) {
40+
e.printStackTrace(System.err);
41+
hasErrors = true;
42+
}
43+
44+
@Override
45+
public void error(String message) {
46+
System.err.println("ERROR[scip-semanticdb]: " + message);
47+
hasErrors = true;
48+
}
49+
50+
@Override
51+
public boolean hasErrors() {
52+
return this.hasErrors;
53+
}
54+
};
3455
ScipSemanticdbOptions scipOptions =
3556
new ScipSemanticdbOptions(
3657
options.targetroots,
3758
options.output,
3859
options.sourceroot,
39-
new ScipSemanticdbReporter() {
40-
@Override
41-
public void error(Throwable e) {
42-
e.printStackTrace(System.err);
43-
}
44-
},
60+
reporter,
4561
LsifToolInfo.newBuilder().setName("scip-java").setVersion("HEAD").build(),
4662
"java",
4763
ScipOutputFormat.TYPED_PROTOBUF,
@@ -50,10 +66,14 @@ public void error(Throwable e) {
5066
"",
5167
true);
5268
ScipSemanticdb.run(scipOptions);
69+
5370
if (!scipOptions.reporter.hasErrors()) {
5471
System.out.println("done: " + scipOptions.output);
72+
return 0;
73+
} else {
74+
System.out.println("SCIP index generation failed");
75+
return 1;
5576
}
56-
return 0;
5777
}
5878

5979
public static List<MavenPackage> mavenPackages(BazelOptions options)

0 commit comments

Comments
 (0)