summaryrefslogtreecommitdiff
path: root/antlr4-maven-plugin/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'antlr4-maven-plugin/src/test')
-rw-r--r--antlr4-maven-plugin/src/test/java/org/antlr/mojo/antlr4/Antlr4MojoTest.java361
-rw-r--r--antlr4-maven-plugin/src/test/projects/dependencyRemoved/pom.xml33
-rw-r--r--antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/imports/HelloBase.g416
-rw-r--r--antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/test/Hello.g47
-rw-r--r--antlr4-maven-plugin/src/test/projects/importTokens/pom.xml33
-rw-r--r--antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/imports/SimpleLexer.tokens3
-rw-r--r--antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/test/SimpleParser.g48
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsCustom/pom.xml48
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/Hello.g44
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestLexer.g46
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestParser.g45
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/imports/TestBaseLexer.g416
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml33
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/imports/TestBaseLexer.g416
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/Hello.g44
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestLexer.g46
-rw-r--r--antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestParser.g45
17 files changed, 604 insertions, 0 deletions
diff --git a/antlr4-maven-plugin/src/test/java/org/antlr/mojo/antlr4/Antlr4MojoTest.java b/antlr4-maven-plugin/src/test/java/org/antlr/mojo/antlr4/Antlr4MojoTest.java
new file mode 100644
index 0000000..12c45cd
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/java/org/antlr/mojo/antlr4/Antlr4MojoTest.java
@@ -0,0 +1,361 @@
+/*
+ * Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+package org.antlr.mojo.antlr4;
+
+import io.takari.maven.testing.TestMavenRuntime;
+import io.takari.maven.testing.TestResources;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.MojoExecution;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+
+public class Antlr4MojoTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Rule
+ public final TestResources resources = new TestResources();
+
+ @Rule
+ public final TestMavenRuntime maven = new TestMavenRuntime();
+
+ @Test
+ public void importTokens() throws Exception {
+ Path baseDir = resources.getBasedir("importTokens").toPath();
+ Path antlrDir = baseDir.resolve("src/main/antlr4");
+ Path generatedSources = baseDir.resolve("target/generated-sources/antlr4");
+
+ Path genParser = generatedSources.resolve("test/SimpleParser.java");
+ Path tokens = antlrDir.resolve("imports/SimpleLexer.tokens");
+
+ MavenProject project = maven.readMavenProject(baseDir.toFile());
+ MavenSession session = maven.newMavenSession(project);
+ MojoExecution exec = maven.newMojoExecution("antlr4");
+
+ ////////////////////////////////////////////////////////////////////////
+ // 1st - all grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ assertFalse(Files.exists(genParser));
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Files.exists(genParser));
+
+ ////////////////////////////////////////////////////////////////////////
+ // 2nd - nothing has been modified, no grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ {
+ byte[] sum = checksum(genParser);
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Arrays.equals(sum, checksum(genParser)));
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // 3rd - the imported grammar changed, every dependency has to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ try(Change change = Change.of(tokens, "DOT=4")) {
+ byte[] sum = checksum(genParser);
+
+ maven.executeMojo(session, project, exec);
+
+ assertFalse(Arrays.equals(sum, checksum(genParser)));
+ }
+ }
+
+ @Test
+ public void importsCustomLayout() throws Exception {
+ Path baseDir = resources.getBasedir("importsCustom").toPath();
+ Path antlrDir = baseDir.resolve("src/main/antlr4");
+ Path generatedSources = baseDir.resolve("src/main/java");
+
+ Path genTestLexer = generatedSources.resolve("foo/TestLexer.java");
+ Path genTestParser = generatedSources.resolve("foo/TestParser.java");
+ Path genHello = generatedSources.resolve("foo/HelloParser.java");
+
+ Path baseGrammar = antlrDir.resolve("imports/TestBaseLexer.g4");
+ Path lexerGrammar = antlrDir.resolve("TestLexer.g4");
+ Path parserGrammar = antlrDir.resolve("TestParser.g4");
+
+ Xpp3Dom outputDirectory = TestMavenRuntime.newParameter("outputDirectory",
+ "src/main/java/foo");
+ Xpp3Dom arguments = new Xpp3Dom("arguments");
+ arguments.addChild(TestMavenRuntime.newParameter("argument", "-package"));
+ arguments.addChild(TestMavenRuntime.newParameter("argument", "foo"));
+
+ MavenProject project = maven.readMavenProject(baseDir.toFile());
+ MavenSession session = maven.newMavenSession(project);
+ MojoExecution exec = maven.newMojoExecution("antlr4", outputDirectory, arguments);
+
+ ////////////////////////////////////////////////////////////////////////
+ // 1st - all grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ assertFalse(Files.exists(genHello));
+ assertFalse(Files.exists(genTestParser));
+ assertFalse(Files.exists(genTestLexer));
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Files.exists(genHello));
+ assertTrue(Files.exists(genTestParser));
+ assertTrue(Files.exists(genTestLexer));
+
+ ////////////////////////////////////////////////////////////////////////
+ // 2nd - nothing has been modified, no grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertTrue(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // 3rd - the imported grammar changed, every dependency has to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ // modify the grammar to make checksum comparison detect a change
+ try(Change change = Change.of(baseGrammar, "DOT: '.' ;")) {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertFalse(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // 4th - the lexer grammar changed, the parser grammar has to be processed as well
+ ////////////////////////////////////////////////////////////////////////
+
+ // modify the grammar to make checksum comparison detect a change
+ try(Change change = Change.of(lexerGrammar, "fragment DOT : '.';")) {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertFalse(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // 5th - the parser grammar changed, no other grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ // modify the grammar to make checksum comparison detect a change
+ try(Change change = Change.of(parserGrammar, " t : WS* ;")) {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+ }
+
+ @Test
+ public void importsStandardLayout() throws Exception {
+ Path baseDir = resources.getBasedir("importsStandard").toPath();
+ Path antlrDir = baseDir.resolve("src/main/antlr4");
+ Path generatedSources = baseDir.resolve("target/generated-sources/antlr4");
+
+ Path genTestLexer = generatedSources.resolve("test/TestLexer.java");
+ Path genTestParser = generatedSources.resolve("test/TestParser.java");
+ Path genHello = generatedSources.resolve("test/HelloParser.java");
+
+ Path baseGrammar = antlrDir.resolve("imports/TestBaseLexer.g4");
+ Path lexerGrammar = antlrDir.resolve("test/TestLexer.g4");
+ Path parserGrammar = antlrDir.resolve("test/TestParser.g4");
+
+ MavenProject project = maven.readMavenProject(baseDir.toFile());
+ MavenSession session = maven.newMavenSession(project);
+ MojoExecution exec = maven.newMojoExecution("antlr4");
+
+ ////////////////////////////////////////////////////////////////////////
+ // 1st - all grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ assertFalse(Files.exists(genHello));
+ assertFalse(Files.exists(genTestParser));
+ assertFalse(Files.exists(genTestLexer));
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Files.exists(genHello));
+ assertTrue(Files.exists(genTestParser));
+ assertTrue(Files.exists(genTestLexer));
+
+ ////////////////////////////////////////////////////////////////////////
+ // 2nd - nothing has been modified, no grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertTrue(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // 3rd - the imported grammar changed, every dependency has to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ // modify the grammar to make checksum comparison detect a change
+ try(Change change = Change.of(baseGrammar, "DOT: '.' ;")) {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertFalse(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // 4th - the lexer grammar changed, the parser grammar has to be processed as well
+ ////////////////////////////////////////////////////////////////////////
+
+ // modify the grammar to make checksum comparison detect a change
+ try(Change change = Change.of(lexerGrammar)) {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertFalse(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // 5th - the parser grammar changed, no other grammars have to be processed
+ ////////////////////////////////////////////////////////////////////////
+
+ // modify the grammar to make checksum comparison detect a change
+ try(Change change = Change.of(parserGrammar, " t : WS* ;")) {
+ byte[] testLexerSum = checksum(genTestLexer);
+ byte[] testParserSum = checksum(genTestParser);
+ byte[] helloSum = checksum(genHello);
+
+ maven.executeMojo(session, project, exec);
+
+ assertTrue(Arrays.equals(testLexerSum, checksum(genTestLexer)));
+ assertFalse(Arrays.equals(testParserSum, checksum(genTestParser)));
+ assertTrue(Arrays.equals(helloSum, checksum(genHello)));
+ }
+ }
+
+ @Test
+ public void processWhenDependencyRemoved() throws Exception {
+ Path baseDir = resources.getBasedir("dependencyRemoved").toPath();
+ Path antlrDir = baseDir.resolve("src/main/antlr4");
+
+ Path baseGrammar = antlrDir.resolve("imports/HelloBase.g4");
+
+ MavenProject project = maven.readMavenProject(baseDir.toFile());
+ MavenSession session = maven.newMavenSession(project);
+ MojoExecution exec = maven.newMojoExecution("antlr4");
+
+ maven.executeMojo(session, project, exec);
+
+ try(Change temp = Change.of(baseGrammar)) {
+ // if the base grammar no longer exists, processing must be performed
+ Files.delete(baseGrammar);
+
+ thrown.expect(MojoExecutionException.class);
+ thrown.expectMessage("ANTLR 4 caught 1 build errors.");
+
+ maven.executeMojo(session, project, exec);
+ }
+ }
+
+ private byte[] checksum(Path path) throws IOException {
+ return MojoUtils.checksum(path.toFile());
+ }
+
+ private static class Change implements AutoCloseable {
+ final Path file;
+ final byte[] original;
+
+ public Change(Path file, String change) {
+ this.file = file;
+
+ try {
+ original = Files.readAllBytes(file);
+ } catch (IOException ex) {
+ throw new RuntimeException("Could not read file " + file);
+ }
+
+ String text = new String(original, StandardCharsets.UTF_8) + change;
+
+ write(file, text.getBytes(StandardCharsets.UTF_8));
+ }
+
+ private void write(Path file, byte[] data) {
+ try {
+ Files.write(file, data);
+ } catch (IOException ex) {
+ throw new RuntimeException("Could not write file " + file);
+ }
+ }
+
+ public static Change of(Path file, String change) {
+ return new Change(file, change);
+ }
+
+ public static Change of(Path file) {
+ return new Change(file, "\n");
+ }
+
+ @Override
+ public void close() {
+ write(file, original);
+ }
+ }
+}
diff --git a/antlr4-maven-plugin/src/test/projects/dependencyRemoved/pom.xml b/antlr4-maven-plugin/src/test/projects/dependencyRemoved/pom.xml
new file mode 100644
index 0000000..3163b81
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/dependencyRemoved/pom.xml
@@ -0,0 +1,33 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>deps.removed</groupId>
+ <artifactId>depRemoved</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Test processing after dependency removed</name>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <configuration>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/imports/HelloBase.g4 b/antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/imports/HelloBase.g4
new file mode 100644
index 0000000..5fcc6d3
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/imports/HelloBase.g4
@@ -0,0 +1,16 @@
+lexer grammar TestBaseLexer;
+
+tokens { Name }
+
+// Default "mode": Everything OUTSIDE of a tag
+Comment : '<!--' .*? '-->' ;
+CDSect : '<![CDATA[' .*? ']]>' ;
+
+fragment
+Whitespace : ' ' | '\n' | '\t' | '\r' ;
+
+fragment
+Hexdigit : [a-fA-F0-9] ;
+
+fragment
+Digit : [0-9] ;
diff --git a/antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/test/Hello.g4 b/antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/test/Hello.g4
new file mode 100644
index 0000000..54f998c
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/dependencyRemoved/src/main/antlr4/test/Hello.g4
@@ -0,0 +1,7 @@
+grammar Hello;
+
+import HelloBase;
+
+r : 'hello' ID ;
+ID : [a-z]+ ;
+WS : [ \r\t\n]+ -> skip ;
diff --git a/antlr4-maven-plugin/src/test/projects/importTokens/pom.xml b/antlr4-maven-plugin/src/test/projects/importTokens/pom.xml
new file mode 100644
index 0000000..478b517
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importTokens/pom.xml
@@ -0,0 +1,33 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>import.tokens</groupId>
+ <artifactId>importTokens</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Test importing tokens file</name>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <configuration>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/imports/SimpleLexer.tokens b/antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/imports/SimpleLexer.tokens
new file mode 100644
index 0000000..4637d6e
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/imports/SimpleLexer.tokens
@@ -0,0 +1,3 @@
+ID=1
+INT=2
+SEMI=3
diff --git a/antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/test/SimpleParser.g4 b/antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/test/SimpleParser.g4
new file mode 100644
index 0000000..bbd8274
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importTokens/src/main/antlr4/test/SimpleParser.g4
@@ -0,0 +1,8 @@
+parser grammar SimpleParser;
+options {
+ // get token types from SimpleLexer.tokens; don't name it
+ // SimpleParser.tokens as ANTLR will overwrite!
+ tokenVocab=SimpleLexer;
+}
+
+s : ( ID | INT )* SEMI ;
diff --git a/antlr4-maven-plugin/src/test/projects/importsCustom/pom.xml b/antlr4-maven-plugin/src/test/projects/importsCustom/pom.xml
new file mode 100644
index 0000000..a5826bc
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsCustom/pom.xml
@@ -0,0 +1,48 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>imports.custom</groupId>
+ <artifactId>importsCustom</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Test importing, custom layout</name>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <configuration>
+ <outputDirectory>${basedir}/src/main/java/com/foo</outputDirectory>
+ <arguments>
+ <argument>-visitor</argument>
+ <argument>-no-listener</argument>
+ <argument>-Xlog</argument>
+ <argument>-package</argument>
+ <argument>com.foo</argument>
+ </arguments>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>antlr4</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/Hello.g4 b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/Hello.g4
new file mode 100644
index 0000000..e38ac87
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/Hello.g4
@@ -0,0 +1,4 @@
+grammar Hello;
+r : 'hello' ID ;
+ID : [a-z]+ ;
+WS : [ \r\t\n]+ -> skip ; \ No newline at end of file
diff --git a/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestLexer.g4 b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestLexer.g4
new file mode 100644
index 0000000..668b764
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestLexer.g4
@@ -0,0 +1,6 @@
+lexer grammar TestLexer;
+
+import TestBaseLexer;
+
+WS : Whitespace+ -> skip;
+TEXT : ~[<&]+ ; // match any 16 bit char other than < and & \ No newline at end of file
diff --git a/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestParser.g4 b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestParser.g4
new file mode 100644
index 0000000..5c25961
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/TestParser.g4
@@ -0,0 +1,5 @@
+parser grammar TestParser;
+
+options { tokenVocab=TestLexer; }
+
+document : (Comment | Name) EOF ; \ No newline at end of file
diff --git a/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/imports/TestBaseLexer.g4 b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/imports/TestBaseLexer.g4
new file mode 100644
index 0000000..5fcc6d3
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsCustom/src/main/antlr4/imports/TestBaseLexer.g4
@@ -0,0 +1,16 @@
+lexer grammar TestBaseLexer;
+
+tokens { Name }
+
+// Default "mode": Everything OUTSIDE of a tag
+Comment : '<!--' .*? '-->' ;
+CDSect : '<![CDATA[' .*? ']]>' ;
+
+fragment
+Whitespace : ' ' | '\n' | '\t' | '\r' ;
+
+fragment
+Hexdigit : [a-fA-F0-9] ;
+
+fragment
+Digit : [0-9] ;
diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml b/antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml
new file mode 100644
index 0000000..77f63a2
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsStandard/pom.xml
@@ -0,0 +1,33 @@
+<!--
+ ~ Copyright (c) 2012-2016 The ANTLR Project. All rights reserved.
+ ~ Use of this file is governed by the BSD 3-clause license that
+ ~ can be found in the LICENSE.txt file in the project root.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>imports.standard</groupId>
+ <artifactId>importsStandard</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Test importing, standard layout</name>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <configuration>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/imports/TestBaseLexer.g4 b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/imports/TestBaseLexer.g4
new file mode 100644
index 0000000..5fcc6d3
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/imports/TestBaseLexer.g4
@@ -0,0 +1,16 @@
+lexer grammar TestBaseLexer;
+
+tokens { Name }
+
+// Default "mode": Everything OUTSIDE of a tag
+Comment : '<!--' .*? '-->' ;
+CDSect : '<![CDATA[' .*? ']]>' ;
+
+fragment
+Whitespace : ' ' | '\n' | '\t' | '\r' ;
+
+fragment
+Hexdigit : [a-fA-F0-9] ;
+
+fragment
+Digit : [0-9] ;
diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/Hello.g4 b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/Hello.g4
new file mode 100644
index 0000000..e38ac87
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/Hello.g4
@@ -0,0 +1,4 @@
+grammar Hello;
+r : 'hello' ID ;
+ID : [a-z]+ ;
+WS : [ \r\t\n]+ -> skip ; \ No newline at end of file
diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestLexer.g4 b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestLexer.g4
new file mode 100644
index 0000000..668b764
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestLexer.g4
@@ -0,0 +1,6 @@
+lexer grammar TestLexer;
+
+import TestBaseLexer;
+
+WS : Whitespace+ -> skip;
+TEXT : ~[<&]+ ; // match any 16 bit char other than < and & \ No newline at end of file
diff --git a/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestParser.g4 b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestParser.g4
new file mode 100644
index 0000000..5c25961
--- /dev/null
+++ b/antlr4-maven-plugin/src/test/projects/importsStandard/src/main/antlr4/test/TestParser.g4
@@ -0,0 +1,5 @@
+parser grammar TestParser;
+
+options { tokenVocab=TestLexer; }
+
+document : (Comment | Name) EOF ; \ No newline at end of file