Skip to content

Commit a197d58

Browse files
committed
If any errors were reported, fail BazelBuildTool with code 1
1 parent a28db33 commit a197d58

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

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

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

3333
List<MavenPackage> mavenPackages = mavenPackages(options);
34-
ScipSemanticdbOptions scipOptions =
35-
new ScipSemanticdbOptions(
36-
options.targetroots,
37-
options.output,
38-
options.sourceroot,
34+
ScipSemanticdbReporter reporter =
3935
new ScipSemanticdbReporter() {
36+
private boolean hasErrors = false;
4037
@Override
4138
public void error(Throwable e) {
4239
e.printStackTrace(System.err);
40+
hasErrors = true;
4341
}
44-
},
42+
43+
@Override
44+
public void error(String message) {
45+
System.err.println("ERROR[scip-semanticdb]: " + message);
46+
hasErrors = true;
47+
}
48+
49+
@Override
50+
public boolean hasErrors() {
51+
return this.hasErrors;
52+
}
53+
};
54+
ScipSemanticdbOptions scipOptions =
55+
new ScipSemanticdbOptions(
56+
options.targetroots,
57+
options.output,
58+
options.sourceroot,
59+
reporter,
4560
LsifToolInfo.newBuilder().setName("scip-java").setVersion("HEAD").build(),
4661
"java",
4762
ScipOutputFormat.TYPED_PROTOBUF,
@@ -50,10 +65,14 @@ public void error(Throwable e) {
5065
"",
5166
true);
5267
ScipSemanticdb.run(scipOptions);
68+
5369
if (!scipOptions.reporter.hasErrors()) {
54-
System.out.println("done: " + scipOptions.output);
70+
System.out.println("done: " + scipOptions.output);
71+
return 0;
72+
} else {
73+
System.out.println("SCIP index generation failed");
74+
return 1;
5575
}
56-
return 0;
5776
}
5877

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

0 commit comments

Comments
 (0)