Optional ant tasks in separate build.xml file invoked with Maven AntRun plugin

In a legacy development project, ant build.xml files are used for compilation and packaging. To integrate new features more easily, I decided to use Maven and the AntRun plugin. The original targets can simply be invoked as it is explained in the examples.

However, if you want to use taks not included in the default jar, e.g. the optional ant tasks, you have to correctly add the dependencies to the AntRun plugin. Unfortunately, I moved the dependencies to the global section of my pom.xml. This mistake took me a quite some time to fix, as I simply oversaw it. 🙁

Just make sure, it looks like this:

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <dependencies>
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant-nodeps</artifactId>
      <version>1.7.0</version>
    </dependency>
  </dependencies>
  <executions>
    <execution>
    ...
    </execution>
  </executions>
</plugin>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.