source: other-projects/trunk/realistic-books/packages/AntInstaller/web/manual/manual/CoreTasks/uptodate.html@ 19253

Last change on this file since 19253 was 19253, checked in by davidb, 15 years ago

Establishing a source code repository for Veronica's Realistic Book's software

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