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.

apply.html 9.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Apply Task</title>
  5. </head>
  6. <body>
  7. <h2><a name="apply">Apply/<i>ExecOn</i></a></h2>
  8. <p><i>The name <code>execon</code> is deprecated and only kept for backwards
  9. compatibility.</i></p>
  10. <h3>Description</h3>
  11. <p>Executes a system command. When the <i>os</i> attribute is specified, then
  12. the command is only executed when Ant is run on one of the specified operating
  13. systems.</p>
  14. <p>The files and/or directories of a number of <a
  15. href="../CoreTypes/fileset.html">FileSet</a>s are passed as arguments
  16. to the system command.</p>
  17. <p>If you specify a nested <a
  18. href="../CoreTypes/mapper.html">mapper</a> and the <i>dest</i> attribute,
  19. the timestamp of each source file is compared to the timestamp of a
  20. target file which is defined by the nested mapper element and searched
  21. for in the given dest.</p>
  22. <p>At least one fileset is required, and you must not specify more than
  23. one mapper.</p>
  24. <h3>Parameters</h3>
  25. <table border="1" cellpadding="2" cellspacing="0">
  26. <tr>
  27. <td valign="top"><b>Attribute</b></td>
  28. <td valign="top"><b>Description</b></td>
  29. <td align="center" valign="top"><b>Required</b></td>
  30. </tr>
  31. <tr>
  32. <td valign="top">executable</td>
  33. <td valign="top">the command to execute without any command line
  34. arguments.</td>
  35. <td align="center" valign="top">Yes</td>
  36. </tr>
  37. <tr>
  38. <td valign="top">dest</td>
  39. <td valign="top">the directory where the &lt;apply&gt; expects the target files will be placed by the
  40. command, when it is executed.
  41. </td>
  42. <td align="center" valign="top">Yes, if you specify a nested mapper</td>
  43. </tr>
  44. <tr>
  45. <td valign="top">dir</td>
  46. <td valign="top">the directory in which the command should be executed.</td>
  47. <td align="center" valign="top">No</td>
  48. </tr>
  49. <tr>
  50. <td valign="top">relative</td>
  51. <td valign="top">whether the filenames should be passed on the
  52. command line as absolute or relative pathnames (relative to the
  53. base directory of the corresponding fileset for source files or
  54. the <i>dest</i> attribute for target files).</td>
  55. <td align="center" valign="top">No, default is <i>false</i></td>
  56. </tr>
  57. <tr>
  58. <td valign="top">os</td>
  59. <td valign="top">list of Operating Systems on which the command may be
  60. executed.</td>
  61. <td align="center" valign="top">No</td>
  62. </tr>
  63. <tr>
  64. <td valign="top">output</td>
  65. <td valign="top">the file to which the output of the command should be
  66. redirected.</td>
  67. <td align="center" valign="top">No</td>
  68. </tr>
  69. <tr>
  70. <td valign="top">append</td>
  71. <td valign="top">whether output should be appended to or overwrite
  72. an existing file. Defaults to false. If you set parallel to
  73. false, you will probably want to set this one to true.</td>
  74. <td align="center" valign="top">No</td>
  75. </tr>
  76. <tr>
  77. <td valign="top">outputproperty</td>
  78. <td valign="top">the name of a property in which the output of the
  79. command should be stored.</td>
  80. <td align="center" valign="top">No</td>
  81. </tr>
  82. <tr>
  83. <td valign="top">resultproperty</td>
  84. <td valign="top">the name of a property in which the return code
  85. of the command should be stored. Only of interest if
  86. failonerror=false. If you set parallel to false, only the result
  87. of the first execution will be stored.</td>
  88. <td align="center" valign="top">No</td>
  89. </tr>
  90. <tr>
  91. <td valign="top">timeout</td>
  92. <td valign="top">Stop the command if it doesn't finish within the
  93. specified time (given in milliseconds).</td>
  94. <td align="center" valign="top">No</td>
  95. </tr>
  96. <tr>
  97. <td valign="top">failonerror</td>
  98. <td valign="top">Stop the buildprocess if the command exits with a
  99. returncode other than 0.</td>
  100. <td align="center" valign="top">No</td>
  101. </tr>
  102. <tr>
  103. <td valign="top">failifexecutionfails</td>
  104. <td valign="top">Stop the build if we can't start the program.
  105. Defaults to true. </td>
  106. <td align="center" valign="top">No</td>
  107. </tr>
  108. <tr>
  109. <td valign="top">skipemptyfilesets</td>
  110. <td valign="top">Don't run the command, if no source files have
  111. been found or are newer than their corresponding target
  112. files.</td>
  113. <td align="center" valign="top">No, default is <i>false</i></td>
  114. </tr>
  115. <tr>
  116. <td valign="top">parallel</td>
  117. <td valign="top">Run the command only once, appending all files as
  118. arguments. If false, command will be executed once for every file.
  119. Defaults to false. </td>
  120. <td align="center" valign="top">No</td>
  121. </tr>
  122. <tr>
  123. <td valign="top">type</td>
  124. <td valign="top">One of <i>file</i>, <i>dir</i> or
  125. <i>both</i>. If set to <i>file</i>, only the names of plain
  126. files will be sent to the command. If set to <i>dir</i>, only
  127. the names of directories are considered.</td>
  128. <td align="center" valign="top">No, default is <i>file</i></td>
  129. </tr>
  130. <tr>
  131. <td valign="top">newenvironment</td>
  132. <td valign="top">Do not propagate old environment when new environment
  133. variables are specified.</td>
  134. <td align="center" valign="top">No, default is <i>false</i></td>
  135. </tr>
  136. <tr>
  137. <td valign="top">vmlauncher</td>
  138. <td valign="top">Run command using the Java VM's execution facilities
  139. where available. If set to false the underlying OS's shell,
  140. either directly or through the antRun scripts, will be used.
  141. Under some operating systems, this gives access to facilities
  142. not normally available through the VM including, under Windows,
  143. being able to execute scripts, rather than their associated
  144. interpreter. If you want to specify the name of the
  145. executable as a relative path to the directory given by the
  146. dir attribute, it may become necessary to set vmlauncher to
  147. false as well.</td>
  148. <td align="center" valign="top">No, default is <i>true</i></td>
  149. </tr>
  150. </table>
  151. <h3>Parameters specified as nested elements</h3>
  152. <h4>fileset</h4>
  153. <p>You can use any number of nested <code>&lt;fileset&gt;</code>
  154. elements to define the files for this task and refer to
  155. <code>&lt;fileset&gt;</code>s defined elsewhere.</p>
  156. <h4>arg</h4>
  157. <p>Command line arguments should be specified as nested
  158. <code>&lt;arg&gt;</code> elements. See <a
  159. href="../using.html#arg">Command line arguments</a>.</p>
  160. <h4>srcfile</h4>
  161. <p>By default the file names of the source files will be added to the
  162. end of the command line. If you need to place it somewhere different,
  163. use a nested <code>&lt;srcfile&gt;</code> element between your
  164. <code>&lt;arg&gt;</code> elements to mark the insertion point.</p>
  165. <h4>targetfile</h4>
  166. <p><code>&lt;targetfile&gt;</code> is similar to
  167. <code>&lt;srcfile&gt;</code> and marks the position of the target
  168. filename on the command line. If omitted, the target filenames will
  169. not be added to the command line at all. This element can only be
  170. specified, if you also define a nested mapper and the <i>dest</i>
  171. attribute.</p>
  172. <h4>env</h4>
  173. <p>It is possible to specify environment variables to pass to the
  174. system command via nested <code>&lt;env&gt;</code> elements. See the
  175. description in the section about <a href="exec.html#env">exec</a></p>
  176. <h3>Examples</h3>
  177. <blockquote><pre>
  178. &lt;apply executable=&quot;ls&quot;&gt;
  179. &lt;arg value=&quot;-l&quot;/&gt;
  180. &lt;fileset dir=&quot;/tmp&quot;&gt;
  181. &lt;patternset&gt;
  182. &lt;exclude name=&quot;**/*.txt&quot;/&gt;
  183. &lt;/patternset&gt;
  184. &lt;/fileset&gt;
  185. &lt;fileset refid=&quot;other.files&quot;/&gt;
  186. &lt;/apply&gt;
  187. </pre></blockquote>
  188. <p>invokes <code>ls -l</code>, adding the absolute filenames of all
  189. files below <code>/tmp</code> not ending in <code>.txt</code> and all
  190. files of the FileSet with <code>id</code> <code>other.files</code> to
  191. the command line.</p>
  192. <blockquote><pre>
  193. &lt;apply executable=&quot;somecommand&quot; parallel=&quot;false&quot;&gt;
  194. &lt;arg value=&quot;arg1&quot;/&gt;
  195. &lt;srcfile/&gt;
  196. &lt;arg value=&quot;arg2&quot;/&gt;
  197. &lt;fileset dir=&quot;/tmp&quot;/&gt;
  198. &lt;/apply&gt;
  199. </pre></blockquote>
  200. <p>invokes <code>somecommand arg1 SOURCEFILENAME arg2</code> for each
  201. file in <code>/tmp</code> replacing SOURCEFILENAME with the absolute
  202. filename of each file in turn. If <code>parallel</code> had been set
  203. to true, SOURCEFILENAME would be replaced with the absolute filenames
  204. of all files separated by spaces.</p>
  205. <blockquote><pre>
  206. &lt;apply executable=&quot;cc&quot; dest=&quot;src/C&quot; parallel=&quot;false&quot;&gt;
  207. &lt;arg value=&quot;-c&quot;/&gt;
  208. &lt;arg value=&quot;-o&quot;/&gt;
  209. &lt;targetfile/&gt;
  210. &lt;srcfile/&gt;
  211. &lt;fileset dir=&quot;src/C&quot; includes=&quot;*.c&quot;/&gt;
  212. &lt;mapper type=&quot;glob&quot; from=&quot;*.c&quot; to=&quot;*.o&quot;/&gt;
  213. &lt;/apply&gt;
  214. </pre></blockquote>
  215. <p>invokes <code>cc -c -o TARGETFILE SOURCEFILE</code> for each
  216. <code>.c</code> file that is newer than the corresponding
  217. <code>.o</code>, replacing TARGETFILE with the absolute filename of
  218. the <code>.o</code> and SOURCEFILE with the absolute name of the
  219. <code>.c</code> file.</p>
  220. <hr><p align="center">Copyright &copy; 2000-2002 Apache Software Foundation. All rights
  221. Reserved.</p>
  222. </body>
  223. </html>