Run Ant with IF ELSE from Maven

You already know how to run Ant from Maven (if not, read Run Ant from Maven) , and you need to use IF ELSE, but you don’t know how to do that.

This page is for you.

Full Code:

What you need to run this:

  • Maven 3


Your goal is that you want to use IF ELSE in build.xml, like this:

You need to use Ant-Contrib .  You have to download from ant-contrib-1.0b3.jar from

Assume that you have your project in:

Then keep the jar file in

Then add these line in your build.xml

The full code of build.xml looks like this:

Then try to this command in console:

Then you will see this in your console:


Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">