How can I reuse an ant snippet in multiple projects? Lets say I have the following in my root pom.xml
:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>gen-index</id>
<phase>package</phase>
<configuration>
<target>
... some non-trivial ant stuff here ...
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
<execution>
</executions>
</plugin>
How can I have this ant snippet executed for selected sub-projects? I've tried adding the <plugin>...</plugin>
part above to <pluginManagement>...
, but I can't figure out how to specify for which sub-projects the ant snippet should be run.
i assume that your plugin definition with your target implementation is inside a pluginManagement section of a parent pom.xml
your ant target is inside a execution identified by "gen-index". it should be work if you declare some thing like this in your child project (but this time not inside a pluginManagement section...!!!):
this executes the target inherited by the parent pom with the same identifiert.
i hope this works four you. i used this several times like this..
with this constellation you could have more than one inside the same plugin in your parent pom.xml.
I have created a GitHub repository with a working example: https://github.com/StefanHeimberg/stackoverflow-16056194