From abb52f281a5a9856ae618894e9c26b70eace82fc Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 24 Jun 2024 20:57:45 -0700 Subject: [PATCH 1/3] Ensure execution stops on failure --- .../rife/bld/extension/Antlr4Operation.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/rife/bld/extension/Antlr4Operation.java b/src/main/java/rife/bld/extension/Antlr4Operation.java index 620bc21..a06e3ea 100644 --- a/src/main/java/rife/bld/extension/Antlr4Operation.java +++ b/src/main/java/rife/bld/extension/Antlr4Operation.java @@ -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,10 @@ public class Antlr4Operation extends AbstractOperation { } 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_); @@ -83,9 +87,14 @@ public class Antlr4Operation extends AbstractOperation { 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(1); } } From ed274864fb802a3b506c9a035edd1c47c476ad10 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Wed, 26 Jun 2024 13:36:42 -0700 Subject: [PATCH 2/3] Revised previous commit for 2.0.0-SNAPSHOT --- lib/bld/bld-wrapper.properties | 2 +- src/main/java/rife/bld/extension/Antlr4Operation.java | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index 8022d33..82d5159 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -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 diff --git a/src/main/java/rife/bld/extension/Antlr4Operation.java b/src/main/java/rife/bld/extension/Antlr4Operation.java index a06e3ea..73f07df 100644 --- a/src/main/java/rife/bld/extension/Antlr4Operation.java +++ b/src/main/java/rife/bld/extension/Antlr4Operation.java @@ -52,10 +52,7 @@ public class Antlr4Operation extends AbstractOperation { } if (sources.isEmpty()) { - if (!silent()) { - System.out.println("ERROR: no ANTLR grammars found."); - } - throw new ExitStatusException(1); + throw new IllegalArgumentException("ERROR: no ANTLR grammars found."); } var arguments = new ArrayList<>(arguments_); From e0dd63bd1387e137cd706a31a466d4b94dee5431 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Wed, 26 Jun 2024 17:37:30 -0700 Subject: [PATCH 3/3] Update src/main/java/rife/bld/extension/Antlr4Operation.java Co-authored-by: Geert Bevin --- src/main/java/rife/bld/extension/Antlr4Operation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/rife/bld/extension/Antlr4Operation.java b/src/main/java/rife/bld/extension/Antlr4Operation.java index 73f07df..b9119e3 100644 --- a/src/main/java/rife/bld/extension/Antlr4Operation.java +++ b/src/main/java/rife/bld/extension/Antlr4Operation.java @@ -91,7 +91,7 @@ public class Antlr4Operation extends AbstractOperation { System.out.println("ANTLR4 grammar processed successfully."); } } else { - throw new ExitStatusException(1); + throw new ExitStatusException(ExitStatusException.EXIT_FAILURE); } }