title: execute Ant task if TWO conditions are met
body: <p>The above <a href="/questions/tagged/ant" class="post-tag" title="show questions tagged &#39;ant&#39;" rel="tag">ant</a> script implements <code><strong>if</strong> dir_is_empty <strong>then</strong> git-clone <strong>else</strong> git-fetch</code> using Ant-1.7.1 core statements:</p>
  
  <pre><code>&lt;target name="update" depends="git.clone, git.fetch" /&gt;
  
  &lt;target name="check.dir"&gt;
    &lt;fileset dir="${dir}" id="fileset"/&gt;
    &lt;pathconvert refid="fileset" property="dir.contains-files" setonempty="false"/&gt;
  &lt;/target&gt;
  
  &lt;target name="git.clone" depends="check.dir" unless="dir.contains-files"&gt;
    &lt;exec executable="git"&gt;
      &lt;arg value="clone"/&gt;
      &lt;arg value="${repo}"/&gt;
      &lt;arg value="${dir}"/&gt;
    &lt;/exec&gt;
  &lt;/target&gt;
  
  &lt;target name="git.fetch" depends="check.dir" if="dir.contains-files" &gt;
    &lt;exec executable="git" dir="${dir}"&gt;
      &lt;arg value="fetch"/&gt;
    &lt;/exec&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>(see <a href="https://stackoverflow.com/a/18086175/938111">my other post</a>)</p>
  
  <hr>
  
  <p><strong>But how to implement a <code>target</code> enabled by two conditions?</strong></p>
  
  <p><code>if <strong>dir_does_not_exist</strong> or <strong>dir_is_empty</strong> then git-clone else git-fetch</code></p>
  
  <p>my current attempt:</p>
  
  <pre><code>&lt;target name="git.clone" 
          depends="chk.exist, chk.empty" 
          unless="!dir.exist || dir.noempty" &gt;
    [...]
  &lt;/target&gt;
  
  &lt;target name="chk.exist"&gt;
    &lt;condition property="dir.exist"&gt;
      &lt;available file="${dir}/.git" type="dir"/&gt;
    &lt;/condition&gt;
  &lt;/target&gt;
  
  [...]
  </code></pre>
  
  <hr>
  
  <p>I would prefer Ant-1.7.1 core statements. But I am open about other possibilities as <a href="https://stackoverflow.com/a/14509079/938111">Ant contrib</a>, or <a href="https://stackoverflow.com/a/14509912/938111">embedded script</a>... Feel free to post your ideas...</p>
  
  <p>(See also question <a href="https://stackoverflow.com/q/14562904/938111">Execute ANT task just if a condition is met</a>)</p>