source: release-kits/lirk3/resources/gs3-release-maker/ant/docs/manual/CoreTasks/uptodate.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 6.0 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Language" content="en-us">
5<title>Uptodate Task</title>
6<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
7</head>
8
9<body>
10
11<h2><a name="uptodate">Uptodate</a></h2>
12<h3>Description</h3>
13<p>Sets a property if a target file or set of target files is more up-to-date
14than a source file or set of source files. A single source file is specified
15using the <code>srcfile</code> attribute. A set of source files is specified
16using the nested <code>&lt;srcfiles&gt;</code>
17elements. These are <a href="../CoreTypes/fileset.html">FileSet</a>s,
18whereas multiple target files are specified using a nested
19<a href="../CoreTypes/mapper.html"><code>&lt;mapper&gt;</code></a> element.</p>
20<p>By default, the value of the property is set to <code>true</code> if
21the timestamp of the source file(s) is not more recent than the timestamp of
22the corresponding target file(s). You can set the value to something other
23than the default by specifying the <code>value</code> attribute.</p>
24<p>If a <code>&lt;srcfiles&gt;</code> element is used, without also specifying
25a <code>&lt;mapper&gt;</code> element, the default behavior is to use a
26<a href="../CoreTypes/mapper.html#merge-mapper">merge mapper</a>, with the
27<code>to</code> attribute set to the value of the
28<code>targetfile</code> attribute.</p>
29<p>Normally, this task is used to set properties that are useful to avoid
30target execution depending on the relative age of the specified files.</p>
31<h3>Parameters</h3>
32<table border="1" cellpadding="2" cellspacing="0">
33 <tr>
34 <td valign="top"><b>Attribute</b></td>
35 <td valign="top"><b>Description</b></td>
36 <td align="center" valign="top"><b>Required</b></td>
37 </tr>
38 <tr>
39 <td valign="top">property</td>
40 <td valign="top">The name of the property to set.</td>
41 <td valign="top" align="center">Yes</td>
42 </tr>
43 <tr>
44 <td valign="top">value</td>
45 <td valign="top">The value to set the property to.</td>
46 <td valign="top" align="center">No; defaults to <code>true</code>.</td>
47 </tr>
48 <tr>
49 <td valign="top">srcfile</td>
50 <td valign="top">The file to check against the target file(s).</td>
51 <td valign="top" align="center">Yes, unless a nested
52 <code>&lt;srcfiles&gt;</code> element is present.</td>
53 </tr>
54 <tr>
55 <td valign="top">targetfile</td>
56 <td valign="top">The file for which we want to determine the status.</td>
57 <td valign="top" align="center">Yes, unless a nested
58 <code>&lt;mapper&gt;</code> element is present.</td>
59 </tr>
60</table>
61
62<h3>Parameters specified as nested elements</h3>
63<h4><a name="srcfiles">srcfiles</a></h4>
64<p>The nested <code>&lt;srcfiles&gt;</code> element allows you to specify a
65set of files to check against the target file(s).</p>
66
67<p><strong>Note:</strong> You can specify either the <code>srcfile</code>
68attribute or nested <code>&lt;srcfiles&gt;</code> elements, but not both.
69
70<h4><a name="mapper">mapper</a></h4>
71<p>The nested <code>&lt;mapper&gt;</code> element allows you to specify
72a set of target files to check for being up-to-date with respect to a
73set of source files.</p>
74 <p>
75 The mapper "to" attribute is relative to the target file, or to
76 the "dir" attribute of the nested srcfiles element.
77 </p>
78 <p>
79 <em>Since Ant 1.6.3</em>,
80 one can use a filenamemapper type in place of the mapper element.
81 </p>
82<h3>Examples</h3>
83<pre> &lt;uptodate property=&quot;xmlBuild.notRequired&quot; targetfile=&quot;${deploy}\xmlClasses.jar&quot; &gt;
84 &lt;srcfiles dir= &quot;${src}/xml&quot; includes=&quot;**/*.dtd&quot;/&gt;
85 &lt;/uptodate&gt;</pre>
86<p>sets the property <code>xmlBuild.notRequired</code> to <code>true</code>
87if the <code>${deploy}/xmlClasses.jar</code> file is more up-to-date than
88any of the DTD files in the <code>${src}/xml</code> directory.</p>
89<p>This can be written as:</p>
90<pre> &lt;uptodate property=&quot;xmlBuild.notRequired&quot;&gt;
91 &lt;srcfiles dir= &quot;${src}/xml&quot; includes=&quot;**/*.dtd&quot;/&gt;
92 &lt;mapper type=&quot;merge&quot; to=&quot;${deploy}\xmlClasses.jar&quot;/&gt;
93 &lt;/uptodate&gt;</pre>
94as well.
95
96The <code>xmlBuild.notRequired</code> property can then be used in a
97<code>&lt;target&gt;</code> tag's <code>unless</code> attribute to
98conditionally run that target. For example, running the following target:</p>
99<pre>
100&lt;target name=&quot;xmlBuild&quot; depends=&quot;chkXmlBuild&quot; unless=&quot;xmlBuild.notRequired&quot;&gt;
101 ...
102&lt;/target&gt;
103</pre>
104will first run the <code>chkXmlBuild</code> target, which contains
105the <code>&lt;uptodate&gt;</code> task that determines whether
106<code>xmlBuild.notRequired</code> gets set. The property named in
107the <code>unless</code> attribute is then checked for being set/not set.
108If it did get set (ie., the jar file is up-to-date),
109then the <code>xmlBuild</code> target won't be run.
110</p>
111
112<p> The following example shows a single source file being checked
113against a single target file:</p>
114<pre> &lt;uptodate property=&quot;isUpToDate&quot;
115 srcfile=&quot;/usr/local/bin/testit&quot;
116 targetfile=&quot;${build}/.flagfile&quot;/&gt;
117</pre>
118<p>sets the property <code>isUpToDate</code> to <code>true</code>
119if <code>/usr/local/bin/testit</code> is not newer than
120<code>${build}/.flagfile</code>.</p>
121</p>
122 <p>
123 The following shows usage of a relative mapper.
124 </p>
125 <pre>
126 &lt;uptodate property="checkUptodate.uptodate"&gt;
127 &lt;srcfiles dir="src" includes="*"/&gt;
128 &lt;mapper type="merge" to="../dest/output.done"/&gt;
129 &lt;/uptodate&gt;
130 &lt;echo message="checkUptodate result: ${checkUptodate.uptodate}"/&gt;
131 </pre>
132 <p>
133 The previous example can be a bit confusing, so it may be better to
134 use absolute paths:
135 </p>
136 <pre>
137 &lt;property name="dest.dir" location="dest"/&gt;
138 &lt;uptodate property="checkUptodate.uptodate"&gt;
139 &lt;srcfiles dir="src" includes="*"/&gt;
140 &lt;mapper type="merge" to="${dest.dir}/output.done"/&gt;
141 &lt;/uptodate&gt;
142 </pre>
143
144<hr>
145<p align="center">Copyright &copy; 2000-2005 The Apache Software Foundation.
146All rights Reserved.</p>
147
148</body>
149</html>
150
Note: See TracBrowser for help on using the repository browser.