You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

uptodate.html 5.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Uptodate Task</title>
  5. </head>
  6. <body>
  7. <h2><a name="uptodate">Uptodate</a></h2>
  8. <h3>Description</h3>
  9. <p>Sets a property if a target file or set of target files is more up-to-date
  10. than a source file or set of source files. A single source file is specified
  11. using the <code>srcfile</code> attribute. A set of source files is specified
  12. using the nested <code>&lt;srcfiles&gt;</code>
  13. elements. These are <a href="../CoreTypes/fileset.html">FileSet</a>s,
  14. whereas multiple target files are specified using a nested
  15. <a href="../CoreTypes/mapper.html"><code>&lt;mapper&gt;</code></a> element.</p>
  16. <p>By default, the value of the property is set to <code>true</code> if
  17. the timestamp of the target file(s) is more recent than the timestamp of
  18. the corresponding source file(s). You can set the value to something other
  19. than the default by specifying the <code>value</code> attribute.</p>
  20. <p>If a <code>&lt;srcfiles&gt;</code> element is used, without also specifying
  21. a <code>&lt;mapper&gt;</code> element, the default behavior is to use a
  22. <a href="../CoreTypes/mapper.html#merge-mapper">merge mapper</a>, with the
  23. <code>to</code> attribute set to the value of the
  24. <code>targetfile</code> attribute.</p>
  25. <p>Normally, this task is used to set properties that are useful to avoid
  26. target execution depending on the relative age of the specified files.</p>
  27. <h3>Parameters</h3>
  28. <table border="1" cellpadding="2" cellspacing="0">
  29. <tr>
  30. <td valign="top"><b>Attribute</b></td>
  31. <td valign="top"><b>Description</b></td>
  32. <td align="center" valign="top"><b>Required</b></td>
  33. </tr>
  34. <tr>
  35. <td valign="top">property</td>
  36. <td valign="top">The name of the property to set.</td>
  37. <td valign="top" align="center">Yes</td>
  38. </tr>
  39. <tr>
  40. <td valign="top">value</td>
  41. <td valign="top">The value to set the property to.</td>
  42. <td valign="top" align="center">No; defaults to <code>true</code>.</td>
  43. </tr>
  44. <tr>
  45. <td valign="top">srcfile</td>
  46. <td valign="top">The file to check against the target file(s).</td>
  47. <td valign="top" align="center">Yes, unless a nested
  48. <code>&lt;srcfiles&gt;</code> element is present.</td>
  49. </tr>
  50. <tr>
  51. <td valign="top">targetfile</td>
  52. <td valign="top">The file for which we want to determine the status.</td>
  53. <td valign="top" align="center">Yes, unless a nested
  54. <code>&lt;mapper&gt;</code> element is present.</td>
  55. </tr>
  56. </table>
  57. <h3>Parameters specified as nested elements</h3>
  58. <h4><a name="srcfiles">srcfiles</a></h4>
  59. <p>The nested <code>&lt;srcfiles&gt;</code> element allows you to specify a
  60. set of files to check against the target file(s).</p>
  61. <p><strong>Note:</strong> You can specify either the <code>srcfile</code>
  62. attribute or nested <code>&lt;srcfiles&gt;</code> elements, but not both.
  63. <h4><a name="mapper">mapper</a></h4>
  64. <p>The nested <code>&lt;mapper&gt;</code> element allows you to specify
  65. a set of target files to check for being up-to-date with respect to a
  66. set of source files.</p>
  67. <h3>Examples</h3>
  68. <pre> &lt;uptodate property=&quot;xmlBuild.notRequired&quot; targetfile=&quot;${deploy}\xmlClasses.jar&quot; &gt;
  69. &lt;srcfiles dir= &quot;${src}/xml&quot; includes=&quot;**/*.dtd&quot;/&gt;
  70. &lt;/uptodate&gt;</pre>
  71. <p>sets the property <code>xmlBuild.notRequired</code> to <code>true</code>
  72. if the <code>${deploy}/xmlClasses.jar</code> file is more up-to-date than
  73. any of the DTD files in the <code>${src}/xml</code> directory.</p>
  74. <p>This can be written as:</p>
  75. <pre> &lt;uptodate property=&quot;xmlBuild.notRequired&quot;&gt;
  76. &lt;srcfiles dir= &quot;${src}/xml&quot; includes=&quot;**/*.dtd&quot;/&gt;
  77. &lt;mapper type=&quot;merge&quot; to=&quot;${deploy}\xmlClasses.jar&quot;/&gt;
  78. &lt;/uptodate&gt;</pre>
  79. as well.
  80. The <code>xmlBuild.notRequired</code> property can then be used in a
  81. <code>&lt;target&gt;</code> tag's <code>unless</code> attribute to
  82. conditionally run that target. For example, running the following target:</p>
  83. <pre>
  84. &lt;target name=&quot;xmlBuild&quot; depends="chkXmlBuild" unless="xmlBuild.notRequired&quot;&gt;
  85. ...
  86. &lt;/target&gt;
  87. </pre>
  88. will first run the <code>chkXmlBuild</code> target, which contains
  89. the <code>&lt;uptodate&gt;</code> task that determines whether
  90. <code>xmlBuild.notRequired</code> gets set. The property named in
  91. the <code>unless</code> attribute is then checked for being set/not set.
  92. If it did get set (ie., the jar file is up-to-date),
  93. then the <code>xmlBuild</code> target won't be run.
  94. </p>
  95. <p> The following example shows a single source file being checked
  96. against a single target file:</p>
  97. <pre> &lt;uptodate property=&quot;isUpToDate&quot;
  98. srcfile=&quot;/usr/local/bin/testit&quot;
  99. targetfile=&quot;${build}/.flagfile&quot;/&gt;
  100. </pre>
  101. <p>sets the property <code>isUpToDate</code> to <code>true</code>
  102. if <code>/usr/local/bin/testit</code> is newer than
  103. <code>${build}/.flagfile</code>.</p>
  104. </p>
  105. <hr>
  106. <p align="center">Copyright &copy; 2001-2002 Apache Software Foundation.
  107. All rights Reserved.</p>
  108. </body>
  109. </html>