2001-02-13 12:32:01 +00:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Language" content="en-us">
|
2005-03-07 18:09:10 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css"/>
|
2002-02-03 22:00:42 +00:00
|
|
|
<title>Uptodate Task</title>
|
2001-02-13 12:32:01 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<h2><a name="uptodate">Uptodate</a></h2>
|
|
|
|
<h3>Description</h3>
|
2002-03-31 21:21:37 +00:00
|
|
|
<p>Sets a property if a target file or set of target files is more up-to-date
|
|
|
|
than a source file or set of source files. A single source file is specified
|
|
|
|
using the <code>srcfile</code> attribute. A set of source files is specified
|
|
|
|
using the nested <code><srcfiles></code>
|
|
|
|
elements. These are <a href="../CoreTypes/fileset.html">FileSet</a>s,
|
|
|
|
whereas multiple target files are specified using a nested
|
|
|
|
<a href="../CoreTypes/mapper.html"><code><mapper></code></a> element.</p>
|
|
|
|
<p>By default, the value of the property is set to <code>true</code> if
|
2005-02-24 17:54:21 +00:00
|
|
|
the timestamp of the source file(s) is not more recent than the timestamp of
|
|
|
|
the corresponding target file(s). You can set the value to something other
|
2002-03-31 21:21:37 +00:00
|
|
|
than the default by specifying the <code>value</code> attribute.</p>
|
|
|
|
<p>If a <code><srcfiles></code> element is used, without also specifying
|
|
|
|
a <code><mapper></code> element, the default behavior is to use a
|
|
|
|
<a href="../CoreTypes/mapper.html#merge-mapper">merge mapper</a>, with the
|
|
|
|
<code>to</code> attribute set to the value of the
|
|
|
|
<code>targetfile</code> attribute.</p>
|
|
|
|
<p>Normally, this task is used to set properties that are useful to avoid
|
|
|
|
target execution depending on the relative age of the specified files.</p>
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Parameters</h3>
|
|
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<td valign="top"><b>Attribute</b></td>
|
|
|
|
<td valign="top"><b>Description</b></td>
|
|
|
|
<td align="center" valign="top"><b>Required</b></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">property</td>
|
2002-03-31 21:21:37 +00:00
|
|
|
<td valign="top">The name of the property to set.</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
<td valign="top" align="center">Yes</td>
|
|
|
|
</tr>
|
2001-03-29 10:13:07 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">value</td>
|
2002-03-31 21:21:37 +00:00
|
|
|
<td valign="top">The value to set the property to.</td>
|
|
|
|
<td valign="top" align="center">No; defaults to <code>true</code>.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">srcfile</td>
|
2002-04-18 15:49:19 +00:00
|
|
|
<td valign="top">The file to check against the target file(s).</td>
|
2002-03-31 21:21:37 +00:00
|
|
|
<td valign="top" align="center">Yes, unless a nested
|
|
|
|
<code><srcfiles></code> element is present.</td>
|
2001-03-29 10:13:07 +00:00
|
|
|
</tr>
|
2001-02-13 12:32:01 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">targetfile</td>
|
2002-03-31 21:21:37 +00:00
|
|
|
<td valign="top">The file for which we want to determine the status.</td>
|
|
|
|
<td valign="top" align="center">Yes, unless a nested
|
|
|
|
<code><mapper></code> element is present.</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
2002-03-31 21:21:37 +00:00
|
|
|
|
|
|
|
<h3>Parameters specified as nested elements</h3>
|
|
|
|
<h4><a name="srcfiles">srcfiles</a></h4>
|
|
|
|
<p>The nested <code><srcfiles></code> element allows you to specify a
|
|
|
|
set of files to check against the target file(s).</p>
|
|
|
|
|
|
|
|
<p><strong>Note:</strong> You can specify either the <code>srcfile</code>
|
|
|
|
attribute or nested <code><srcfiles></code> elements, but not both.
|
|
|
|
|
|
|
|
<h4><a name="mapper">mapper</a></h4>
|
|
|
|
<p>The nested <code><mapper></code> element allows you to specify
|
|
|
|
a set of target files to check for being up-to-date with respect to a
|
|
|
|
set of source files.</p>
|
2003-11-24 17:20:19 +00:00
|
|
|
<p>
|
|
|
|
The mapper "to" attribute is relative to the target file, or to
|
|
|
|
the "dir" attribute of the nested srcfiles element.
|
|
|
|
</p>
|
2004-12-10 17:10:07 +00:00
|
|
|
<p>
|
|
|
|
<em>Since Ant 1.6.3</em>,
|
|
|
|
one can use a filenamemapper type in place of the mapper element.
|
|
|
|
</p>
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Examples</h3>
|
|
|
|
<pre> <uptodate property="xmlBuild.notRequired" targetfile="${deploy}\xmlClasses.jar" >
|
|
|
|
<srcfiles dir= "${src}/xml" includes="**/*.dtd"/>
|
|
|
|
</uptodate></pre>
|
2002-03-31 21:21:37 +00:00
|
|
|
<p>sets the property <code>xmlBuild.notRequired</code> to <code>true</code>
|
|
|
|
if the <code>${deploy}/xmlClasses.jar</code> file is more up-to-date than
|
|
|
|
any of the DTD files in the <code>${src}/xml</code> directory.</p>
|
|
|
|
<p>This can be written as:</p>
|
|
|
|
<pre> <uptodate property="xmlBuild.notRequired">
|
2001-02-13 12:32:01 +00:00
|
|
|
<srcfiles dir= "${src}/xml" includes="**/*.dtd"/>
|
|
|
|
<mapper type="merge" to="${deploy}\xmlClasses.jar"/>
|
|
|
|
</uptodate></pre>
|
2002-03-31 21:21:37 +00:00
|
|
|
as well.
|
2002-04-01 07:23:13 +00:00
|
|
|
|
|
|
|
The <code>xmlBuild.notRequired</code> property can then be used in a
|
|
|
|
<code><target></code> tag's <code>unless</code> attribute to
|
|
|
|
conditionally run that target. For example, running the following target:</p>
|
|
|
|
<pre>
|
2002-06-01 12:26:43 +00:00
|
|
|
<target name="xmlBuild" depends="chkXmlBuild" unless="xmlBuild.notRequired">
|
2002-04-01 07:23:13 +00:00
|
|
|
...
|
|
|
|
</target>
|
|
|
|
</pre>
|
|
|
|
will first run the <code>chkXmlBuild</code> target, which contains
|
|
|
|
the <code><uptodate></code> task that determines whether
|
|
|
|
<code>xmlBuild.notRequired</code> gets set. The property named in
|
|
|
|
the <code>unless</code> attribute is then checked for being set/not set.
|
|
|
|
If it did get set (ie., the jar file is up-to-date),
|
|
|
|
then the <code>xmlBuild</code> target won't be run.
|
2002-03-31 21:21:37 +00:00
|
|
|
</p>
|
|
|
|
|
2002-04-01 07:23:13 +00:00
|
|
|
<p> The following example shows a single source file being checked
|
|
|
|
against a single target file:</p>
|
2002-03-31 21:21:37 +00:00
|
|
|
<pre> <uptodate property="isUpToDate"
|
|
|
|
srcfile="/usr/local/bin/testit"
|
|
|
|
targetfile="${build}/.flagfile"/>
|
|
|
|
</pre>
|
|
|
|
<p>sets the property <code>isUpToDate</code> to <code>true</code>
|
2005-02-24 17:54:21 +00:00
|
|
|
if <code>/usr/local/bin/testit</code> is not newer than
|
2002-03-31 21:21:37 +00:00
|
|
|
<code>${build}/.flagfile</code>.</p>
|
|
|
|
</p>
|
2003-11-24 17:20:19 +00:00
|
|
|
<p>
|
|
|
|
The following shows usage of a relative mapper.
|
|
|
|
</p>
|
|
|
|
<pre>
|
|
|
|
<uptodate property="checkUptodate.uptodate">
|
2004-11-19 09:07:12 +00:00
|
|
|
<srcfiles dir="src" includes="*"/>
|
2003-11-24 17:20:19 +00:00
|
|
|
<mapper type="merge" to="../dest/output.done"/>
|
|
|
|
</uptodate>
|
2004-11-19 09:07:12 +00:00
|
|
|
<echo message="checkUptodate result: ${checkUptodate.uptodate}"/>
|
2003-11-24 17:20:19 +00:00
|
|
|
</pre>
|
|
|
|
<p>
|
|
|
|
The previous example can be a bit confusing, so it may be better to
|
|
|
|
use absolute paths:
|
|
|
|
</p>
|
|
|
|
<pre>
|
|
|
|
<property name="dest.dir" location="dest"/>
|
|
|
|
<uptodate property="checkUptodate.uptodate">
|
2004-11-19 09:07:12 +00:00
|
|
|
<srcfiles dir="src" includes="*"/>
|
2003-11-24 17:20:19 +00:00
|
|
|
<mapper type="merge" to="${dest.dir}/output.done"/>
|
|
|
|
</uptodate>
|
|
|
|
</pre>
|
2002-03-31 21:21:37 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<hr>
|
2005-02-24 17:54:21 +00:00
|
|
|
<p align="center">Copyright © 2000-2005 The Apache Software Foundation.
|
2002-03-31 21:21:37 +00:00
|
|
|
All rights Reserved.</p>
|
2001-02-13 12:32:01 +00:00
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|