Skip to end of metadata
Go to start of metadata

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:

<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.

  • No labels