From 38739cec5e18a3f9cab9a408b3d9f8fa8c01029e Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sun, 2 Dec 2012 16:57:42 -0600 Subject: [PATCH] Fix handling of grammars in the default package (resolves antlr/antlr4#94) --- .../src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; }