The Antlr Plugin generates files based on grammar file(s). The following examples describe the basic usage of the Plugin.
You must configure the Antlr Plugin as follow:
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>antlr-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<!--
Comma separated list of grammar files or pattern grammar files
By default, grammar file(s) is in ${basedir}/src/main/antlr
-->
<grammars>java.g</grammars>
<!-- <grammars>*.g</grammars> -->
</configuration>
</plugin>
...
</plugins>
</build>
...
</project>To generate files, you should execute the generate goal of the Antlr Plugin, i.e.:
mvn antlr:generate
When you compile your project, the Antlr Plugin could be executed. You should add the <execution> section as follow:
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>antlr-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<!--
Comma separated list of grammar files or pattern grammar files
By default, grammar file(s) is in ${basedir}/src/main/antlr
-->
<grammars>java.g</grammars>
<!-- <grammars>*.g</grammars> -->
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
...
</project>When you execute mvn compile, the files will be generated and included in your compile sources.
To include Antlr reports in your documentation, you must configure the following in the <reporting> section of your pom:
<project>
...
<reporting>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>antlr-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<!--
Comma separated list of grammar files or pattern grammar files
By default, grammar file(s) is in ${basedir}/src/main/antlr
-->
<grammars>java15.g</grammars>
<!-- <grammars>*.g</grammars> -->
</configuration>
</plugin>
...
</plugins>
</reporting>
...
</project>When you execute mvn site, the report will be generated.