Guide to generating sources
Let's run though a short example to try and help. To generate sources you must first have a plugin that participates in the generate-sources phase like the Antlr plugin:
/** * Generates files based on grammar files with Antlr tool. * * @goal generate * @phase generate-sources * @requiresDependencyResolution compile * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> * @version $Id$ */ public class AntlrPlugin extends AbstractAntlrMojo { /** * @see org.apache.maven.plugin.Mojo#execute() */ public void execute() throws MojoExecutionException { executeAntlr(); }
The first two lines say "I want to be fit into the generate-sources phase and my 'handle' is generate".
So this is all fine and dandy, we have a plugin that wants to generate some sources from a Antlr grammar but how do we use it. You need to specify that you want to use it in your POM:
<project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antlr-plugin</artifactId> <version>2.0-beta-1</version> <configuration> <grammars>java.g</grammars> </configuration> <executions> <execution> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> </build> ... </project>
If you then type "mvn compile" Maven will walk through the lifecycle and will eventually hit the generate-sources phase and see you have a plugin configured that wants to participate in that phase and the Antlr plugin is executed with your given configuration.