execute a tarefa Ant se DUAS condições forem atendidas
O de cimaformig script implementa<strong>if</strong> dir_is_empty <strong>then</strong> git-clone <strong>else</strong> git-fetch
usando as instruções principais do Ant-1.7.1:
<target name="update" depends="git.clone, git.fetch" />
<target name="check.dir">
<fileset dir="${dir}" id="fileset"/>
<pathconvert refid="fileset" property="dir.contains-files" setonempty="false"/>
</target>
<target name="git.clone" depends="check.dir" unless="dir.contains-files">
<exec executable="git">
<arg value="clone"/>
<arg value="${repo}"/>
<arg value="${dir}"/>
</exec>
</target>
<target name="git.fetch" depends="check.dir" if="dir.contains-files" >
<exec executable="git" dir="${dir}">
<arg value="fetch"/>
</exec>
</target>
(Vejomy outro post)
Mas como implementar umtarget
ativado por duas condições?
if <strong>dir_does_not_exist</strong> or <strong>dir_is_empty</strong> then git-clone else git-fetch
minha tentativa atual:
<target name="git.clone"
depends="chk.exist, chk.empty"
unless="!dir.exist || dir.noempty" >
[...]
</target>
<target name="chk.exist">
<condition property="dir.exist">
<available file="${dir}/.git" type="dir"/>
</condition>
</target>
[...]
Eu preferiria as declarações principais do Ant-1.7.1. Mas estou aberto a outras possibilidades comoAnt contrib ou script incorporado ... Sinta-se livre para postar suas idéias ...
(Veja também a perguntaExecute a tarefa ANT apenas se uma condição for atendida)