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
|
---|
30 | than a source file or set of source files. A single source file is specified
|
---|
31 | using the <code>srcfile</code> attribute. A set of source files is specified
|
---|
32 | using the nested <code><srcfiles></code>
|
---|
33 | elements. These are <a href="../CoreTypes/fileset.html">FileSet</a>s,
|
---|
34 | whereas multiple target files are specified using a nested
|
---|
35 | <a href="../CoreTypes/mapper.html"><code><mapper></code></a> element.</p>
|
---|
36 | <p>By default, the value of the property is set to <code>true</code> if
|
---|
37 | the timestamp of the source file(s) is not more recent than the timestamp of
|
---|
38 | the corresponding target file(s). You can set the value to something other
|
---|
39 | than the default by specifying the <code>value</code> attribute.</p>
|
---|
40 | <p>If a <code><srcfiles></code> element is used, without also specifying
|
---|
41 | a <code><mapper></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
|
---|
46 | target 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><srcfiles></code> or <code><srcresources></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><mapper></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><srcfiles></code> element allows you to specify a
|
---|
82 | set of files to check against the target file(s).</p>
|
---|
83 |
|
---|
84 | <p><strong>Note:</strong> You can specify either the <code>srcfile</code>
|
---|
85 | attribute or nested <code><srcfiles></code> elements, but not both.
|
---|
86 |
|
---|
87 | <h4><a name="srcresources">srcresources</a></h4>
|
---|
88 | <p>The nested <code><srcresources></code> element is a <a
|
---|
89 | href="../CoreTypes/resources.html#union">union</a> and allows you to
|
---|
90 | specify 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><mapper></code> element allows you to specify
|
---|
95 | a set of target files to check for being up-to-date with respect to a
|
---|
96 | set 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> <uptodate property="xmlBuild.notRequired" targetfile="${deploy}\xmlClasses.jar" >
|
---|
107 | <srcfiles dir= "${src}/xml" includes="**/*.dtd"/>
|
---|
108 | </uptodate></pre>
|
---|
109 | <p>sets the property <code>xmlBuild.notRequired</code> to <code>true</code>
|
---|
110 | if the <code>${deploy}/xmlClasses.jar</code> file is more up-to-date than
|
---|
111 | any of the DTD files in the <code>${src}/xml</code> directory.</p>
|
---|
112 | <p>This can be written as:</p>
|
---|
113 | <pre> <uptodate property="xmlBuild.notRequired">
|
---|
114 | <srcfiles dir= "${src}/xml" includes="**/*.dtd"/>
|
---|
115 | <mapper type="merge" to="${deploy}\xmlClasses.jar"/>
|
---|
116 | </uptodate></pre>
|
---|
117 | <p>as well.</p>
|
---|
118 | <p>
|
---|
119 | The <code>xmlBuild.notRequired</code> property can then be used in a
|
---|
120 | <code><target></code> tag's <code>unless</code> attribute to
|
---|
121 | conditionally run that target. For example, running the following target:</p>
|
---|
122 | <pre>
|
---|
123 | <target name="xmlBuild" depends="chkXmlBuild" unless="xmlBuild.notRequired">
|
---|
124 | ...
|
---|
125 | </target>
|
---|
126 | </pre>
|
---|
127 | <p>
|
---|
128 | will first run the <code>chkXmlBuild</code> target, which contains
|
---|
129 | the <code><uptodate></code> task that determines whether
|
---|
130 | <code>xmlBuild.notRequired</code> gets set. The property named in
|
---|
131 | the <code>unless</code> attribute is then checked for being set/not set.
|
---|
132 | If it did get set (ie., the jar file is up-to-date),
|
---|
133 | then the <code>xmlBuild</code> target won't be run.
|
---|
134 | </p>
|
---|
135 |
|
---|
136 | <p> The following example shows a single source file being checked
|
---|
137 | against a single target file:</p>
|
---|
138 | <pre> <uptodate property="isUpToDate"
|
---|
139 | srcfile="/usr/local/bin/testit"
|
---|
140 | targetfile="${build}/.flagfile"/>
|
---|
141 | </pre>
|
---|
142 | <p>sets the property <code>isUpToDate</code> to <code>true</code>
|
---|
143 | if <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 | <uptodate property="checkUptodate.uptodate">
|
---|
151 | <srcfiles dir="src" includes="*"/>
|
---|
152 | <mapper type="merge" to="../dest/output.done"/>
|
---|
153 | </uptodate>
|
---|
154 | <echo message="checkUptodate result: ${checkUptodate.uptodate}"/>
|
---|
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 | <property name="dest.dir" location="dest"/>
|
---|
162 | <uptodate property="checkUptodate.uptodate">
|
---|
163 | <srcfiles dir="src" includes="*"/>
|
---|
164 | <mapper type="merge" to="${dest.dir}/output.done"/>
|
---|
165 | </uptodate>
|
---|
166 | </pre>
|
---|
167 |
|
---|
168 |
|
---|
169 |
|
---|
170 | </body>
|
---|
171 | </html>
|
---|
172 |
|
---|