title: Run a Ant task in Maven only if a property is set
body: <p>My <code>pom.xml</code> is running an Ant task to deploy a file using FTP. However, this deployment must be only done if the <code>-Dftp=true</code> argument is given in the Maven command (i.e. <code>mvn clean install -Dftp=true</code>). Thus, I wrote the following code:</p>
  
  <pre><code>&lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.2&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;run&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;tasks if="ftp"&gt;
                              &lt;echo message="Deploying files through FTP..."/&gt;
                              ...
                          &lt;/tasks&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
  </code></pre>
  
  <p>Using this <code>pom.xml</code>, the Ant task is not executed if I do not define the <code>-Dftp</code> property in my Maven command. However, if I give any kind of value for this property, for example <code>-Dftp=false</code>, the Ant task is run, which is not correct.</p>
  
  <p>How configure the AntRun task to be run only if a given property has a given value?</p>
  
  <p>ps: I know I can use a <code>profile</code> that is only active when <code>ftp</code> is equal to <code>true</code>. This solution works, but for some reason, I want to have my Antrun plugin <code>build</code> block.</p>
  
  <pre><code>&lt;profiles&gt;
      &lt;profile&gt;
          &lt;id&gt;deployment&lt;/id&gt;
          &lt;activation&gt;
              &lt;activeByDefault&gt;false&lt;/activeByDefault&gt;
              &lt;property&gt;
                  &lt;name&gt;ftp&lt;/name&gt;
                  &lt;value&gt;true&lt;/value&gt;
              &lt;/property&gt;
          &lt;/activation&gt;
          &lt;build&gt;
              &lt;plugins&gt;
                  &lt;plugin&gt;
                      ... (define the Ant task here)
  </code></pre>