выполнить задачу Ant, если ДВЕ выполнены условия
Надмураве скрипт реализует<strong>if</strong> dir_is_empty <strong>then</strong> git-clone <strong>else</strong> git-fetch
используя основные выражения 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>
(видеть мой другой пост)
Но как реализоватьtarget
разрешено двумя условиями?
if <strong>dir_does_not_exist</strong> or <strong>dir_is_empty</strong> then git-clone else git-fetch
Моя текущая попытка:
<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>
[...]
Я бы предпочел основные утверждения Ant-1.7.1. Но я открыт для других возможностей, как Не участвует, или встроенный скрипт ... Не стесняйтесь публиковать свои идеи ...
(См. Также вопрос Выполнить задачу ANT, только если условие выполнено)