Maven – Add ant-contrib Ant Tasks in maven-antrun-plugin

Ant Tasks, such as <if>, belongs to ant-contrib.jar. So in order to use them in maven-antrun-plugin, you have to add this dependency explicitly in the pom.xml.

<!-- Properties -->

<!-- Build Configuration -->
              <!-- add the ant tasks from ant-contrib -->
              <taskdef resource="net/sf/antcontrib/" />
              <!-- show greeting if ${greeting} is set to true-->
                <equals arg1="${greeting}" arg2="true" />
                  <echo>Hello World</echo>

Please remember to add the tasks definition of ant-contrib.jar using the <taskdef> inside the <tasks> node.

Run mvn initialize, the console will echo the greeting message only if the ${greeting} property is set to true.

Done =)


4 thoughts on “Maven – Add ant-contrib Ant Tasks in maven-antrun-plugin”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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