Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you force maven to execute antrun:run task after all the package tasks in a POM with child modules?

Tags:

maven-2

I have a parent POM with a bunch of child modules. I want to run an antrun:run task after all the children have executed a package task (I'm using Ant to package my app since i gave up figuring out how to get assembly to work correctly).

I need to have the antrun task execute after all the children - but I can't associate it with package phase since parent gets "packaged" before children, and i need ant to run afterwards.

Is there a way to do it in one command?

Easy workaround, of course, is to run 2 maven commands:

mvn package; mvn antrun:run

But i want to do it in one, if possible

mvn package antrun:run

produces wrong behaviour - it runs antrun:run before child projects' package phase.

Ideally, i'd be able to just type

mvn package

And have that run package phase on all children, and then run antrun:run on parent.

like image 470
toli Avatar asked Jul 30 '10 21:07

toli


2 Answers

I need to have the antrun task execute after all the children - but I can't associate it with package phase since parent gets "packaged" before children, and i need ant to run afterwards.

Create another module that depends on all children (so that it will be the last project during a reactor build) and bind your antrun stuff on package in this module. Then just run mvn package from the root project.

like image 122
Pascal Thivent Avatar answered Sep 30 '22 03:09

Pascal Thivent


Put

<inherited>false</inherited> 

in your plugin definition:

<plugin>
<artifactId>maven-antrun-plugin</artifactId>    
           <inherited>false</inherited>
              <executions>
                 <execution>
                   <phase>compile</phase>
                   <configuration>

                     <tasks>
                       <ant antfile="buildall.xml">

                       </ant>
                    </tasks>
                 </configuration>
                 <goals>
                    <goal>run</goal>
                </goals>
              </execution>
           </executions>
       </plugin>
like image 30
Gwen Avatar answered Sep 30 '22 05:09

Gwen