title: Maven multiple modules - post-packaging step
body: <p>I have a Maven project that consists of several modules.  I have a single POM file that I use to invoke the build of all dependent modules.  What I want to do is to copy a bunch of files to a single location and zip them up once, after the package lifecycle of all the sub-modules has completed.</p>
  
  <p>I've looked into antrun, but can't see how to make it run once.  Currently it runs during the package phase of each module.  Here's my parent POM file (simplified)</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.example&lt;/groupId&gt;
  &lt;artifactId&gt;parent&lt;/artifactId&gt;
  &lt;name&gt;project&lt;/name&gt;
  &lt;version&gt;1.0&lt;/version&gt;
  &lt;packaging&gt;pom&lt;/packaging&gt;
  &lt;modules&gt;
      &lt;module&gt;../module1&lt;/module&gt;
      &lt;module&gt;../module2&lt;/module&gt;
  &lt;/modules&gt;
  &lt;dependencies&gt;
      ...
  &lt;/dependencies&gt;
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;configuration&gt;
                          &lt;tasks&gt;
                              &lt;mkdir dir="product" /&gt;
                              &lt;copy todir="product"&gt;
                                  &lt;fileset dir="../module1/doc/release"&gt;
                                      &lt;include name="*.pdf" /&gt;
                                  &lt;/fileset&gt;
                                  &lt;fileset dir="../module2/doc/release"&gt;
                                      &lt;include name="*.pdf" /&gt;
                                  &lt;/fileset&gt;
                                  &lt;fileset dir="../module1/target"&gt;
                                      &lt;include name="*.war" /&gt;
                                  &lt;/fileset&gt;
                                  &lt;fileset dir="../module2/target"&gt;
                                      &lt;include name="*.war" /&gt;
                                  &lt;/fileset&gt;
                              &lt;/copy&gt;
                              &lt;copy file="app.properties" todir="cesium" /&gt;
  
                              &lt;zip basedir="product" destfile="dist.zip"&gt;&lt;/zip&gt;
  
                          &lt;/tasks&gt;
                      &lt;/configuration&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;run&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  
      &lt;/plugins&gt;
  &lt;/build&gt;
  
  &lt;properties&gt;
      ...
  &lt;/properties&gt;
  </code></pre>
  
  <p></p>
  
  <p>Hopefully it's clear what I'm trying to do.  I just want the antrun task to happen after the package lifecycle, and only once, not for each module.  </p>
  
  <p>I understand that I might not be approaching this step the right way, but I'm unclear how best to aproach this with Maven.  Any thoughts appreciated.</p>