Wrap a bunch of ant tasks in a maven plugin?
I have a bunch of maven projects that needs to execute the same sequence of ant tasks using the maven-antrun-plugin during the build/deploy phase.
I don't want to override the implementation of maven-antrun-plugin in a parent project so all other projects using this plugin will inherit these steps.
I was therefore looking into writing my own maven plugin that works as a maven-antrun-plugin wrapper with a special sequence of ant tasks. But currently I have had no success doing this.
I have looked at:
http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html
but run into the same problem described here:
http://www.mail-archive.com/users@maven.apache.org/msg92676.html
(using the versions suggested in the above post does not solve the problem)
and from : http://www.mail-archive.com/users@maven.apache.org/msg115264.html it looks like the tutorial only works with maven2:
I have also tried to steal something from here:
http://maven.apache.org/guides/plugin/guide-java-plugin-development.html
but still no working plugin.
The plugin that I want to wrap looks like this:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>test</id>
<phase>deploy</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<!-- execute task A,B and D -->
</tasks>
</c开发者_JAVA百科onfiguration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Is it possible to put the sequence of task A, B and C out in another plugin an then use that plugin where ever needed?
I have also tried to move the antrun plugin to a parent and the disable it for some of the children setting inheritance to false:
http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_inherited_Tag_In_Build_Plugins
but the task defined in the parent is still executed so setting the inheritance to false does not seem to work.
If you want to define a <plugin>
in the parent and allow children to use it as appropriate, then you can define it within a <pluginManagement>
section. By doing this, the parent will not execute the plugin. It will execute only for those children which define this plugin in their pom.
As for sequencing of ant tasks, would it not be simpler to create a task
in your ant script, which calls the tasks A, B and C in sequence and continue to use the default maven-antrun-plugin
functionality?
精彩评论