Cari di Apache Ant 
    Apache Ant User Manual
Daftar Isi
(Sebelumnya) UnzipMicrosoft Visual SourceSafe Tasks (Berikutnya)
Apache Ant Tasks

Uptodate

Uptodate

Description

Sets a property if a target file or set of target files is more up-to-datethan a source file or set of source files. A single source file is specifiedusing the srcfile attribute. A set of source files is specifiedusing the nested <srcfiles>elements. These are FileSets,whereas multiple target files are specified using a nested<mapper> element.

By default, the value of the property is set to true ifthe timestamp of the source file(s) is not more recent than the timestamp ofthe corresponding target file(s). You can set the value to something otherthan the default by specifying the value attribute.

If a <srcfiles> element is used, without also specifyinga <mapper> element, the default behavior is to use amerge mapper, with theto attribute set to the value of thetargetfile attribute.

Normally, this task is used to set properties that are useful to avoidtarget execution depending on the relative age of the specified files.

Parameters

Attribute Description Required
property The name of the property to set. Yes
value The value to set the property to. No; defaults to true.
srcfile The file to check against the target file(s). Yes, unless a nested <srcfiles> or <srcresources> element is present.
targetfile The file for which we want to determine the status. Yes, unless a nested <mapper> element is present.

Parameters specified as nested elements

srcfiles

The nested <srcfiles> element is afileset and allows you tospecify a set of files to check against the target file(s).

Note: You can specify either the srcfileattribute or nested <srcfiles> elements, but not both.

Note that the task will completely ignore any directories that seem to be matched by the srcfiles fileset, it will only consider normal files. If you need logic that applies to directories as well, use a nested srcresource and a dirset (for example).

srcresources

The nested <srcresources> element is a union and allows you tospecify a collection of resources to check against the target file(s).Since Apache Ant 1.7

mapper

The nested <mapper> element allows you to specifya set of target files to check for being up-to-date with respect to aset of source files.

The mapper "to" attribute is relative to the target file, or to the "dir" attribute of the nested srcfiles element.

Since Ant 1.6.3, one can use a filenamemapper type in place of the mapper element.

Examples

  <uptodate property="xmlBuild.notRequired" targetfile="${deploy}xmlClasses.jar" > <srcfiles dir= "${src}/xml" includes="**/*.dtd"/>  </uptodate>

sets the property xmlBuild.notRequired to trueif the ${deploy}/xmlClasses.jar file is more up-to-date thanany of the DTD files in the ${src}/xml directory.

This can be written as:

  <uptodate property="xmlBuild.notRequired"> <srcfiles dir= "${src}/xml" includes="**/*.dtd"/> <mapper type="merge" to="${deploy}xmlClasses.jar"/>  </uptodate>
as well.The xmlBuild.notRequired property can then be used in a<target> tag's unless attribute toconditionally run that target. For example, running the following target:

<target name="xmlBuild" depends="chkXmlBuild" unless="xmlBuild.notRequired">  ...</target>
will first run the chkXmlBuild target, which containsthe <uptodate> task that determines whetherxmlBuild.notRequired gets set. The property named inthe unless attribute is then checked for being set/not set.If it did get set (ie., the jar file is up-to-date),then the xmlBuild target won't be run.

The following example shows a single source file being checkedagainst a single target file:

  <uptodate property="isUpToDate" srcfile="/usr/local/bin/testit" targetfile="${build}/.flagfile"/>

sets the property isUpToDate to trueif /usr/local/bin/testit is not newer than${build}/.flagfile.

The following shows usage of a relative mapper.

 <uptodate property="checkUptodate.uptodate">  <srcfiles dir="src" includes="*"/>  <mapper type="merge" to="../dest/output.done"/> </uptodate> <echo message="checkUptodate result: ${checkUptodate.uptodate}"/>  

The previous example can be a bit confusing, so it may be better to use absolute paths:

 <property name="dest.dir" location="dest"/> <uptodate property="checkUptodate.uptodate">  <srcfiles dir="src" includes="*"/>  <mapper type="merge" to="${dest.dir}/output.done"/> </uptodate>  
(Sebelumnya) UnzipMicrosoft Visual SourceSafe Tasks (Berikutnya)