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
|
---|
14 | than a source file or set of source files. A single source file is specified
|
---|
15 | using the <code>srcfile</code> attribute. A set of source files is specified
|
---|
16 | using the nested <code><srcfiles></code>
|
---|
17 | elements. These are <a href="../CoreTypes/fileset.html">FileSet</a>s,
|
---|
18 | whereas multiple target files are specified using a nested
|
---|
19 | <a href="../CoreTypes/mapper.html"><code><mapper></code></a> element.</p>
|
---|
20 | <p>By default, the value of the property is set to <code>true</code> if
|
---|
21 | the timestamp of the source file(s) is not more recent than the timestamp of
|
---|
22 | the corresponding target file(s). You can set the value to something other
|
---|
23 | than the default by specifying the <code>value</code> attribute.</p>
|
---|
24 | <p>If a <code><srcfiles></code> element is used, without also specifying
|
---|
25 | a <code><mapper></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
|
---|
30 | target 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><srcfiles></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><mapper></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><srcfiles></code> element allows you to specify a
|
---|
65 | set of files to check against the target file(s).</p>
|
---|
66 |
|
---|
67 | <p><strong>Note:</strong> You can specify either the <code>srcfile</code>
|
---|
68 | attribute or nested <code><srcfiles></code> elements, but not both.
|
---|
69 |
|
---|
70 | <h4><a name="mapper">mapper</a></h4>
|
---|
71 | <p>The nested <code><mapper></code> element allows you to specify
|
---|
72 | a set of target files to check for being up-to-date with respect to a
|
---|
73 | set 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> <uptodate property="xmlBuild.notRequired" targetfile="${deploy}\xmlClasses.jar" >
|
---|
84 | <srcfiles dir= "${src}/xml" includes="**/*.dtd"/>
|
---|
85 | </uptodate></pre>
|
---|
86 | <p>sets the property <code>xmlBuild.notRequired</code> to <code>true</code>
|
---|
87 | if the <code>${deploy}/xmlClasses.jar</code> file is more up-to-date than
|
---|
88 | any of the DTD files in the <code>${src}/xml</code> directory.</p>
|
---|
89 | <p>This can be written as:</p>
|
---|
90 | <pre> <uptodate property="xmlBuild.notRequired">
|
---|
91 | <srcfiles dir= "${src}/xml" includes="**/*.dtd"/>
|
---|
92 | <mapper type="merge" to="${deploy}\xmlClasses.jar"/>
|
---|
93 | </uptodate></pre>
|
---|
94 | as well.
|
---|
95 |
|
---|
96 | The <code>xmlBuild.notRequired</code> property can then be used in a
|
---|
97 | <code><target></code> tag's <code>unless</code> attribute to
|
---|
98 | conditionally run that target. For example, running the following target:</p>
|
---|
99 | <pre>
|
---|
100 | <target name="xmlBuild" depends="chkXmlBuild" unless="xmlBuild.notRequired">
|
---|
101 | ...
|
---|
102 | </target>
|
---|
103 | </pre>
|
---|
104 | will first run the <code>chkXmlBuild</code> target, which contains
|
---|
105 | the <code><uptodate></code> task that determines whether
|
---|
106 | <code>xmlBuild.notRequired</code> gets set. The property named in
|
---|
107 | the <code>unless</code> attribute is then checked for being set/not set.
|
---|
108 | If it did get set (ie., the jar file is up-to-date),
|
---|
109 | then the <code>xmlBuild</code> target won't be run.
|
---|
110 | </p>
|
---|
111 |
|
---|
112 | <p> The following example shows a single source file being checked
|
---|
113 | against a single target file:</p>
|
---|
114 | <pre> <uptodate property="isUpToDate"
|
---|
115 | srcfile="/usr/local/bin/testit"
|
---|
116 | targetfile="${build}/.flagfile"/>
|
---|
117 | </pre>
|
---|
118 | <p>sets the property <code>isUpToDate</code> to <code>true</code>
|
---|
119 | if <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 | <uptodate property="checkUptodate.uptodate">
|
---|
127 | <srcfiles dir="src" includes="*"/>
|
---|
128 | <mapper type="merge" to="../dest/output.done"/>
|
---|
129 | </uptodate>
|
---|
130 | <echo message="checkUptodate result: ${checkUptodate.uptodate}"/>
|
---|
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 | <property name="dest.dir" location="dest"/>
|
---|
138 | <uptodate property="checkUptodate.uptodate">
|
---|
139 | <srcfiles dir="src" includes="*"/>
|
---|
140 | <mapper type="merge" to="${dest.dir}/output.done"/>
|
---|
141 | </uptodate>
|
---|
142 | </pre>
|
---|
143 |
|
---|
144 | <hr>
|
---|
145 | <p align="center">Copyright © 2000-2005 The Apache Software Foundation.
|
---|
146 | All rights Reserved.</p>
|
---|
147 |
|
---|
148 | </body>
|
---|
149 | </html>
|
---|
150 |
|
---|