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.

execon.html 6.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Ant User Manual</title>
  5. </head>
  6. <body>
  7. <h2><a name="execon">ExecOn</a></h2>
  8. <h3>Description</h3>
  9. <p>Executes a system command. When the <i>os</i> attribute is specified, then
  10. the command is only executed when Ant is run on one of the specified operating
  11. systems.</p>
  12. <p>The files and/or directories of a number of <a
  13. href="../CoreTypes/fileset.html">FileSet</a>s are passed as arguments to the system
  14. command. At least one nested <code>&lt;fileset&gt;</code> is required.</p>
  15. <h3>Parameters</h3>
  16. <table border="1" cellpadding="2" cellspacing="0">
  17. <tr>
  18. <td valign="top"><b>Attribute</b></td>
  19. <td valign="top"><b>Description</b></td>
  20. <td align="center" valign="top"><b>Required</b></td>
  21. </tr>
  22. <tr>
  23. <td valign="top">executable</td>
  24. <td valign="top">the command to execute without any command line
  25. arguments.</td>
  26. <td align="center" valign="top">Yes</td>
  27. </tr>
  28. <tr>
  29. <td valign="top">dir</td>
  30. <td valign="top">the directory in which the command should be executed.</td>
  31. <td align="center" valign="top">No</td>
  32. </tr>
  33. <tr>
  34. <td valign="top">os</td>
  35. <td valign="top">list of Operating Systems on which the command may be
  36. executed.</td>
  37. <td align="center" valign="top">No</td>
  38. </tr>
  39. <tr>
  40. <td valign="top">output</td>
  41. <td valign="top">the file to which the output of the command should be
  42. redirected.</td>
  43. <td align="center" valign="top">No</td>
  44. </tr>
  45. <tr>
  46. <td valign="top">timeout</td>
  47. <td valign="top">Stop the command if it doesn't finish within the
  48. specified time (given in milliseconds).</td>
  49. <td align="center" valign="top">No</td>
  50. </tr>
  51. <tr>
  52. <td valign="top">failonerror</td>
  53. <td valign="top">Stop the buildprocess if the command exits with a
  54. returncode other than 0.</td>
  55. <td align="center" valign="top">No</td>
  56. </tr>
  57. <tr>
  58. <td valign="top">newenvironment</td>
  59. <td valign="top">Do not propagate old environment when new environment
  60. variables are specified.</td>
  61. <td align="center" valign="top">No, default is <i>false</i></td>
  62. </tr>
  63. <tr>
  64. <td valign="top">vmlauncher</td>
  65. <td valign="top">Run command using the Java VM's execution facilities
  66. where available. If set to false the underlying OS's shell,
  67. either directly or through the antRun scripts, will be used.
  68. Under some operating systems, this gives access to facilities
  69. not nomrally available through the VM including, under Windows,
  70. being able to execute scripts, rather than their associated
  71. interpreter.</td>
  72. <td align="center" valign="top">No, default is <i>true</i></td>
  73. </tr>
  74. <tr>
  75. <td valign="top">skipemptyfilesets</td>
  76. <td valign="top">Don't run the command, if no source files have
  77. been found.</td>
  78. <td align="center" valign="top">No, default is <i>false</i></td>
  79. </tr>
  80. <tr>
  81. <td valign="top">parallel</td>
  82. <td valign="top">Run the command only once, appending all files as
  83. arguments. If false, command will be executed once for every file.
  84. Defaults to false. </td>
  85. <td align="center" valign="top">No</td>
  86. </tr>
  87. <tr>
  88. <td valign="top">type</td>
  89. <td valign="top">One of <i>file</i>, <i>dir</i> or
  90. <i>both</i>. If set to <i>file</i>, only the names of plain
  91. files will be sent to the command. If set to <i>dir</i>, only
  92. the names of directories are considered.</td>
  93. <td align="center" valign="top">No, default is <i>file</i></td>
  94. </tr>
  95. </table>
  96. <h3>Parameters specified as nested elements</h3>
  97. <h4>fileset</h4>
  98. <p>You can use any number of nested <code>&lt;fileset&gt;</code>
  99. elements to define the files for this task and refer to
  100. <code>&lt;fileset&gt;</code>s defined elsewhere.</p>
  101. <h4>arg</h4>
  102. <p>Command line arguments should be specified as nested
  103. <code>&lt;arg&gt;</code> elements. See <a
  104. href="../using.html#arg">Command line arguments</a>.</p>
  105. <h4>srcfile</h4>
  106. <p>By default the file names of the source files will be added to the
  107. end of the command line. If you need to place it somewhere different,
  108. use a nested <code>&lt;srcfile&gt;</code> element between your
  109. <code>&lt;arg&gt;</code> elements to mark the insertion point.</p>
  110. <h4>env</h4>
  111. <p>It is possible to specify environment variables to pass to the
  112. system command via nested <code>&lt;env&gt;</code> elements. See the
  113. description in the section about <a href="exec.html#env">exec</a></p>
  114. <p>Please note that the environment of the current Ant process is
  115. <b>not</b> passed to the system command if you specify variables using
  116. <code>&lt;env&gt;</code>.</p>
  117. <h3>Examples</h3>
  118. <blockquote><pre>
  119. &lt;execon executable=&quot;ls&quot; &gt;
  120. &lt;arg value=&quot;-l&quot;/&gt;
  121. &lt;fileset dir=&quot;/tmp&quot;&gt;
  122. &lt;patternset&gt;
  123. &lt;exclude name=&quot;**/*.txt&quot;/&gt;
  124. &lt;/patternset&gt;
  125. &lt;/fileset&gt;
  126. &lt;fileset refid=&quot;other.files&quot;/&gt;
  127. &lt;/execon&gt;
  128. </pre></blockquote>
  129. <p>invokes <code>ls -l</code>, adding the absolute filenames of all
  130. files below <code>/tmp</code> not ending in <code>.txt</code> and all
  131. files of the FileSet with <code>id</code> <code>other.files</code> to
  132. the command line.</p>
  133. <blockquote><pre>
  134. &lt;execon executable=&quot;somecommand&quot; parallel=&quot;false&quot; &gt;
  135. &lt;arg value=&quot;arg1&quot;/&gt;
  136. &lt;srfile/&gt;
  137. &lt;arg value=&quot;arg2&quot;/&gt;
  138. &lt;fileset dir=&quot;/tmp&quot;/&gt;
  139. &lt;/execon&gt;
  140. </pre></blockquote>
  141. <p>invokes <code>somecommand arg1 SOURCEFILENAME arg2</code> for each
  142. file in <code>/tmp</code> replacing SOURCEFILENAME with the absolute
  143. filename of each file in turn. If <code>parallel</code> had been set
  144. to true, SOURCEFILENAME would be replaced with the absolute filenames
  145. of all files separated by spaces.</p>
  146. <hr>
  147. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  148. Reserved.</p>
  149. </body>
  150. </html>