Powyższy ant skryptu implementuje if dir_is_empty then git-clone else git-fetch
użyciu ANT-1.7.1 podstawowych sprawozdań:wykonać zadanie Ant, jeśli spełnione są dwa warunki
<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>
(patrz my other post)
Ale jak zaimplementować target
włączone przez dwa warunki?
if dir_does_not_exist or dir_is_empty then git-clone else git-fetch
moja obecna próba:
<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>
[...]
wolałbym Ant-1.7.1 podstawowych oświadczenia. Ale jestem otwarty na temat innych możliwości jak Ant contrib lub embedded script ... Zapraszam do zamieścić swoje pomysły ...
(Patrz również pytanie Execute ANT task just if a condition is met)