Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Although not explicitly mentioned in the Maven Ant guide, it is possible to define multiple Ant executions (each with it's own id) in a single project descriptor, and each execution could be attached to different build lifecycle phases. An example would be the following:

No Format
<project>
  ...

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>task1</id>
            <phase>clean</phase>
            <configuration>
              <tasks>
                <!-- Some task -->
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>

          <execution>
            <id>task2</id>
            <phase>compile</phase>
            <configuration>
              <tasks>
                <!-- Some task -->
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>

        </executions>
      </plugin>
    </plugins>
  </build>

</project>

Although not highlighted in the code snippet above, the key is having the plugins/plugin/executions/execution/id element defined.