parent
33ac0c3611
commit
5d4efafe8e
|
@ -150,6 +150,13 @@ public class Antlr4Mojo extends AbstractMojo {
|
|||
@Parameter(property = "project", required = true, readonly = true)
|
||||
protected MavenProject project;
|
||||
|
||||
/**
|
||||
* Specifies whether sources are added to the {@code compile} or
|
||||
* {@code test} scope.
|
||||
*/
|
||||
@Parameter(property = "antlr4.generateTestSources", defaultValue = "false")
|
||||
private boolean generateTestSources;
|
||||
|
||||
/**
|
||||
* The directory where the ANTLR grammar files ({@code *.g4}) are located.
|
||||
*/
|
||||
|
@ -190,7 +197,12 @@ public class Antlr4Mojo extends AbstractMojo {
|
|||
}
|
||||
|
||||
void addSourceRoot(File outputDir) {
|
||||
project.addCompileSourceRoot(outputDir.getPath());
|
||||
if (generateTestSources) {
|
||||
project.addTestCompileSourceRoot(outputDir.getPath());
|
||||
}
|
||||
else {
|
||||
project.addCompileSourceRoot(outputDir.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4-runtime</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.antlr</groupId>
|
||||
|
@ -129,7 +129,9 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<sourceDirectory>${basedir}/test</sourceDirectory>
|
||||
<outputDirectory>${project.build.directory}/generated-test-sources/antlr4</outputDirectory>
|
||||
<visitor>true</visitor>
|
||||
<generateTestSources>true</generateTestSources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
|
Loading…
Reference in New Issue