lauantai 13. helmikuuta 2010

Apache Ant: Retrieving file only if it does not exist

Apache Ant 1.8 has a nice new feature (thanks to David M. Lloyd) for retrieving files with the get task only if they do not exist locally. The task attribute is called "skipexisting":
<target name="-pre-compile">
  <get src="http://hsql.sourceforge.net/m2-repo/com/h2database/h2/1.2.128/h2-1.2.128.jar"
       dest="lib/h2-stable.jar"
       usetimestamp="true"
       skipexisting="true" />
</target>

Ant 1.7 (or earlier) equivalent would be something like this:

<target name="-pre-compile">
  <available property="exists.h2" file="lib/h2-stable.jar" />
  <antcall target="get-h2" />
</target>

<target name="get-h2" unless="exists.h2">
  <get src="http://hsql.sourceforge.net/m2-repo/com/h2database/h2/1.2.128/h2-1.2.128.jar"
       dest="lib/h2-stable.jar" usetimestamp="true" />
</target>

Ei kommentteja:

Lähetä kommentti