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 5.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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">skipemptyfilesets</td>
  65. <td valign="top">Don't run the command, if no source files have
  66. been found.</td>
  67. <td align="center" valign="top">No, default is <i>false</i></td>
  68. </tr>
  69. <tr>
  70. <td valign="top">parallel</td>
  71. <td valign="top">Run the command only once, appending all files as
  72. arguments. If false, command will be executed once for every file.
  73. Defaults to false. </td>
  74. <td align="center" valign="top">No</td>
  75. </tr>
  76. <tr>
  77. <td valign="top">type</td>
  78. <td valign="top">One of <i>file</i>, <i>dir</i> or
  79. <i>both</i>. If set to <i>file</i>, only the names of plain
  80. files will be sent to the command. If set to <i>dir</i>, only
  81. the names of directories are considered.</td>
  82. <td align="center" valign="top">No, default is <i>file</i></td>
  83. </tr>
  84. </table>
  85. <h3>Parameters specified as nested elements</h3>
  86. <h4>fileset</h4>
  87. <p>You can use any number of nested <code>&lt;fileset&gt;</code>
  88. elements to define the files for this task and refer to
  89. <code>&lt;fileset&gt;</code>s defined elsewhere.</p>
  90. <h4>arg</h4>
  91. <p>Command line arguments should be specified as nested
  92. <code>&lt;arg&gt;</code> elements. See <a
  93. href="../using.html#arg">Command line arguments</a>.</p>
  94. <h4>srcfile</h4>
  95. <p>By default the file names of the source files will be added to the
  96. end of the command line. If you need to place it somewhere different,
  97. use a nested <code>&lt;srcfile&gt;</code> element between your
  98. <code>&lt;arg&gt;</code> elements to mark the insertion point.</p>
  99. <h4>env</h4>
  100. <p>It is possible to specify environment variables to pass to the
  101. system command via nested <code>&lt;env&gt;</code> elements. See the
  102. description in the section about <a href="exec.html#env">exec</a></p>
  103. <p>Please note that the environment of the current Ant process is
  104. <b>not</b> passed to the system command if you specify variables using
  105. <code>&lt;env&gt;</code>.</p>
  106. <h3>Examples</h3>
  107. <blockquote><pre>
  108. &lt;execon executable=&quot;ls&quot; &gt;
  109. &lt;arg value=&quot;-l&quot;/&gt;
  110. &lt;fileset dir=&quot;/tmp&quot;&gt;
  111. &lt;patternset&gt;
  112. &lt;exclude name=&quot;**/*.txt&quot;/&gt;
  113. &lt;/patternset&gt;
  114. &lt;/fileset&gt;
  115. &lt;fileset refid=&quot;other.files&quot;/&gt;
  116. &lt;/execon&gt;
  117. </pre></blockquote>
  118. <p>invokes <code>ls -l</code>, adding the absolute filenames of all
  119. files below <code>/tmp</code> not ending in <code>.txt</code> and all
  120. files of the FileSet with <code>id</code> <code>other.files</code> to
  121. the command line.</p>
  122. <blockquote><pre>
  123. &lt;execon executable=&quot;somecommand&quot; parallel=&quot;false&quot; &gt;
  124. &lt;arg value=&quot;arg1&quot;/&gt;
  125. &lt;srfile/&gt;
  126. &lt;arg value=&quot;arg2&quot;/&gt;
  127. &lt;fileset dir=&quot;/tmp&quot;/&gt;
  128. &lt;/execon&gt;
  129. </pre></blockquote>
  130. <p>invokes <code>somecommand arg1 SOURCEFILENAME arg2</code> for each
  131. file in <code>/tmp</code> replacing SOURCEFILENAME with the absolute
  132. filename of each file in turn. If <code>parallel</code> had been set
  133. to true, SOURCEFILENAME would be replaced with the absolute filenames
  134. of all files separated by spaces.</p>
  135. <hr>
  136. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  137. Reserved.</p>
  138. </body>
  139. </html>