diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java index 8786b3177..22e942ea6 100644 --- a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java +++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java @@ -268,9 +268,9 @@ public class Antlr4Mojo extends AbstractMojo { grammarFiles = getGrammarFiles(sourceDirectory); importGrammarFiles = getImportFiles(sourceDirectory); argumentSets = processGrammarFiles(args, grammarFiles, dependencies, sourceDirectory); - } catch (InclusionScanException ie) { - log.error(ie); - throw new MojoExecutionException("Fatal error occured while evaluating the names of the grammar files to analyze", ie); + } catch (Exception e) { + log.error(e); + throw new MojoExecutionException("Fatal error occured while evaluating the names of the grammar files to analyze", e); } log.debug("Output directory base will be " + outputDirectory.getAbsolutePath()); @@ -385,7 +385,7 @@ public class Antlr4Mojo extends AbstractMojo { List args, Set grammarFiles, GrammarDependencies dependencies, - File sourceDirectory) throws InclusionScanException { + File sourceDirectory) throws InclusionScanException, IOException { // We don't want the plugin to run for every grammar, regardless of whether // it's changed since the last compilation. Check the mtime of the tokens vs diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/GrammarDependencies.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/GrammarDependencies.java index 6dee559ed..9f0fd1415 100644 --- a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/GrammarDependencies.java +++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/GrammarDependencies.java @@ -56,7 +56,7 @@ class GrammarDependencies { * * @return self-reference. */ - public String getPackage(List arguments) { + private String getPackage(List arguments) { int index = (arguments != null) ? arguments.indexOf("-package") : -1; return (index > -1) @@ -90,7 +90,7 @@ class GrammarDependencies { * @return self-reference. */ public GrammarDependencies analyze(Set grammarFiles, - Set importGrammarFiles, Tool tool) { + Set importGrammarFiles, Tool tool) throws IOException { log.debug("Analysing grammar dependencies " + sourceDirectory); // for dependency analysis we require all grammars @@ -141,7 +141,7 @@ class GrammarDependencies { * * @return {@code true} if a grammar used by the given grammar has been modified. */ - public boolean isDependencyChanged(File grammarFile) { + public boolean isDependencyChanged(File grammarFile) throws IOException { String grammarPath = getRelativePath(grammarFile); for (Map.Entry>> e : grammars.entrySet()) { diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/MojoUtils.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/MojoUtils.java index 0a8cf03c3..b8019d88a 100644 --- a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/MojoUtils.java +++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/MojoUtils.java @@ -3,8 +3,10 @@ package org.antlr.mojo.antlr4; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; +import java.io.IOException; import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; class MojoUtils { @@ -15,7 +17,7 @@ class MojoUtils { * * @return the checksum. */ - public static byte[] checksum(File file) { + public static byte[] checksum(File file) throws IOException { try { InputStream in = new FileInputStream(file); byte[] buffer = new byte[2048]; @@ -36,8 +38,8 @@ class MojoUtils { } return complete.digest(); - } catch (Exception ex) { - throw new RuntimeException("Could not create checksum " + file, ex); + } catch (NoSuchAlgorithmException ex) { + throw new IOException("Could not create checksum " + file, ex); } }