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 cfb911b51..51d0c48dc 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 @@ -403,7 +403,7 @@ public class Antlr4Mojo extends AbstractMojo { List> result = new ArrayList>(); for (Map.Entry> entry : grammarFileByFolder.entrySet()) { List folderArgs = new ArrayList(args); - if (!folderArgs.contains("-package")) { + if (!folderArgs.contains("-package") && !entry.getKey().isEmpty()) { folderArgs.add("-package"); folderArgs.add(getPackageName(entry.getKey())); } @@ -457,6 +457,9 @@ public class Antlr4Mojo extends AbstractMojo { } File unprefixedGrammarFileName = new File(grammarFileName.substring(srcPath.length())); + if (unprefixedGrammarFileName.getParent() == null) { + return ""; + } return unprefixedGrammarFileName.getParent() + File.separator; }