使用ant的if unless实现
<property name="destfilename" value="文件路径"/> <target name="detect.file" > <condition property="fileIsExists" > <and> <available file="${destfilename}"/> </and> </condition> </target> <target name="savetosvn" if="fileIsExists"> <echo>savetosvn executing</echo> <antcall target="svncommit"/> </target> <target name="savetosvnnofile" unless="fileIsExists" depends="detect.file,savetosvn"> <echo>savetosvnnofile executing</echo> <antcall target="svncommitwithadd"/> </target>