title: Execute maven ant-run plugin in the end in case of maven parallel builds
body: <p>I am having a maven multi module project. A simplified <code>pom.xml</code> (under <code>full-build</code>) looks like below:-</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
           xmlns="http://maven.apache.org/POM/4.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;packaging&gt;pom&lt;/packaging&gt;
      &lt;groupId&gt;com.eros&lt;/groupId&gt;
      &lt;artifactId&gt;full-build&lt;/artifactId&gt;
      &lt;version&gt;0.001-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;full-build&lt;/name&gt;
      &lt;profiles&gt;
          &lt;profile&gt;
              &lt;id&gt;build-only&lt;/id&gt;
              &lt;activation&gt;
                  &lt;activeByDefault&gt;true&lt;/activeByDefault&gt;
              &lt;/activation&gt;
              &lt;modules&gt;
                  &lt;module&gt;../../main&lt;/module&gt;
              &lt;/modules&gt;
          &lt;/profile&gt;
          &lt;profile&gt;
              &lt;id&gt;copy-only&lt;/id&gt;
              &lt;activation&gt;
                  &lt;activeByDefault&gt;true&lt;/activeByDefault&gt;
              &lt;/activation&gt;
              &lt;build&gt;
                  &lt;plugins&gt;
                      &lt;plugin&gt;
                          &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
                          &lt;version&gt;1.8&lt;/version&gt;
                          &lt;executions&gt;
                              &lt;execution&gt;
                                  &lt;phase&gt;package&lt;/phase&gt;
                                  &lt;configuration&gt;
                                      &lt;tasks&gt;
                                          &lt;!-- collector --&gt;
                                          &lt;copy file="../collector-framework/collector/target/collector-${project.version}.jar"
                                                tofile="./target/collector/collector-${project.version}.jar"/&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;/profile&gt;
      &lt;/profiles&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>The simplified <code>pom.xml</code> inside <code>main</code> looks like below:-</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &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/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.eros&lt;/groupId&gt;
      &lt;artifactId&gt;main&lt;/artifactId&gt;
      &lt;version&gt;0.001-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;pom&lt;/packaging&gt;
      &lt;name&gt;main&lt;/name&gt;
      &lt;modules&gt;
          &lt;module&gt;collector-framework&lt;/module&gt;
      &lt;/modules&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-enforcer-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.4&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;enforce-versions&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;enforce&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;rules&gt;
                                  &lt;requireJavaVersion&gt;
                                      &lt;version&gt;[1.8,)&lt;/version&gt;
                                      &lt;message&gt;*** This project requires JDK 1.8/J2SE 8 or later. ***&lt;/message&gt;
                                  &lt;/requireJavaVersion&gt;
                              &lt;/rules&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.8&lt;/source&gt;
                      &lt;target&gt;1.8&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Whenever I try to execute the above project with <code>mvn clean install -T 4</code> the collector-framework project gets skipped and the build fails with error</p>
  
  <pre><code>Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (default) on project full-build: An Ant BuildException has occured: Warning: Could not find file /Users/tuk/code/github/eros/main/collector-framework/collector/target/collector-0.001-SNAPSHOT.jar to copy.
  [ERROR] around Ant part ...&lt;copy file="../collector-framework/collector/target/collector-0.001-SNAPSHOT.jar" tofile="./target/collector/collector-0.001-SNAPSHOT.jar"/&gt;... @ 4:143 in /Users/tuk/code/github/eros/main/full-build/target/antrun/build-main.xml
  </code></pre>
  
  <p>Everything works fine if I just do <code>mvn clean install</code>. I think this is happening because ant-run is running before the <code>main</code> module execution is finished. Can someone let me know how can I make <code>ant-run</code> wait till main module compilation is over in case of parallel builds?</p>
  
  <ul>
  <li>Maven Version - 3.5.0</li>
  </ul>