Merge pull request #1 from ethauvin/main
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

Ensure execution stops on failure
This commit is contained in:
Geert Bevin 2024-06-26 20:38:05 -04:00 committed by GitHub
commit cb79240c47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View file

@ -3,4 +3,4 @@ bld.downloadExtensionSources=true
bld.extensions=
bld.repositories=MAVEN_CENTRAL,RIFE2_RELEASES
bld.downloadLocation=
bld.version=1.9.1
bld.version=2.0.0-SNAPSHOT

View file

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