2010-06-15 16 views

Odpowiedz

17

Możesz użyć zadania pathconvert, aby to zrobić, z właściwością setonempty. Zobacz this example dla przypadku użycia.

<pathconvert refid="myfileset" 
      property="fileset.notempty" 
      setonempty="false"/> 

będzie ustawić właściwość fileset.notempty tylko jeśli fileset tych refid jest myfileset nie jest pusta.

Trzeba tylko określić myfileset z katalogu, a nie obejmuje żadnych katalogów dostaniesz pusty testu:

<fileset dir="foo/bar" id="myfileset"/> 
3

To jest tylko uzupełnieniem dla tonio's answer.

W tym przykładzie cvs checkout jest emulowany za pomocą git polecenia:

  • git clone gdy dir jest pusty
  • git fetch inny

<target name="cvs_checkout" depends="git.clone, git.fetch" /> 

<target name="git.clone" depends="check.dir" unless="dir.contains-files"> 
    <echo message="Directory ${dir} is empty -} git clone" /> 
    <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"> 
    <echo message="Directory ${dir} contains files -} git fetch" /> 
    <exec executable="git" dir="${dir}"> 
    <arg value="fetch"/> 
    </exec> 
</target> 

<target name="check.dir"> 
    <fileset dir="${dir}" id="fileset"/> 
    <pathconvert refid="fileset" property="dir.contains-files" setonempty="false"/> 
</target> 
Powiązane problemy