È possibile che questo ant sceneggiatura implementa if dir_is_empty then git-clone else git-fetch
usando Ant-1.7.1 affermazioni fondamentali:eseguire task Ant se due condizioni sono soddisfatte
<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>
(vedi my other post)
Ma come implementare un target
abilitato da due condizioni?
if dir_does_not_exist or dir_is_empty then git-clone else git-fetch
mia attuale tentativo:
<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>
[...]
Io preferirei Ant-1.7.1 dichiarazioni core. Ma io sono aperto ad altre possibilità come Ant contrib, o embedded script ... Sentitevi liberi di inviare le vostre idee ...
(Vedere anche domanda Execute ANT task just if a condition is met)