blob: 1575cd057b4c1ce69704ca947ecaec031e1b9ff7 [file] [log] [blame]
------
Guide to generating Sources
------
Jason van Zyl
------
12 October 2005
------
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:
%{snippet|id=generate-sources-0|url=http://svn.codehaus.org/mojo/trunk/mojo/antlr-maven-plugin/src/main/java/org/codehaus/mojo/antlr/AntlrPlugin.java}
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 {{{../introduction/introduction-to-the-lifecycle.html}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.