Ensure execution stops on failure
Some checks failed
bld-ci / build-project (17) (push) Has been cancelled
bld-ci / build-project (19) (push) Has been cancelled
bld-ci / build-project (20) (push) Has been cancelled
javadocs-pages / deploy (push) Has been cancelled

This commit is contained in:
Erik C. Thauvin 2024-06-24 20:57:45 -07:00
parent 2c7f9f9e3e
commit abb52f281a
Signed by: erik
GPG key ID: 776702A6A2DA330E

View file

@ -6,6 +6,7 @@ package rife.bld.extension;
import org.antlr.v4.Tool; import org.antlr.v4.Tool;
import rife.bld.operations.AbstractOperation; import rife.bld.operations.AbstractOperation;
import rife.bld.operations.exceptions.ExitStatusException;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
@ -51,7 +52,10 @@ public class Antlr4Operation extends AbstractOperation<Antlr4Operation> {
} }
if (sources.isEmpty()) { if (sources.isEmpty()) {
throw new IllegalArgumentException("ERROR: no ANTLR grammars found"); if (!silent()) {
System.out.println("ERROR: no ANTLR grammars found.");
}
throw new ExitStatusException(1);
} }
var arguments = new ArrayList<>(arguments_); var arguments = new ArrayList<>(arguments_);
@ -83,9 +87,14 @@ public class Antlr4Operation extends AbstractOperation<Antlr4Operation> {
var argument_array = new String[arguments.size()]; var argument_array = new String[arguments.size()];
arguments.toArray(argument_array); arguments.toArray(argument_array);
new Tool(argument_array).processGrammarsOnCommandLine(); var tool = new Tool(argument_array);
if (!silent()) { tool.processGrammarsOnCommandLine();
System.out.println("ANTLR4 grammar processed successfully."); if (tool.getNumErrors() == 0) {
if (!silent()) {
System.out.println("ANTLR4 grammar processed successfully.");
}
} else {
throw new ExitStatusException(1);
} }
} }