2006-09-11 04:19:00 +00:00
|
|
|
<!--
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
-->
|
2005-02-07 23:42:21 +00:00
|
|
|
<html>
|
2001-02-13 12:32:01 +00:00
|
|
|
|
|
|
|
<head>
|
2007-05-02 06:15:35 +00:00
|
|
|
<meta http-equiv="Content-Language" content="en-us">
|
|
|
|
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
|
|
|
<title>Exec Task</title>
|
2001-02-13 12:32:01 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<h2><a name="exec">Exec</a></h2>
|
|
|
|
<h3>Description</h3>
|
|
|
|
<p>Executes a system command. When the <i>os</i> attribute is specified, then
|
|
|
|
the command is only executed when Ant is run on one of the specified operating
|
|
|
|
systems.</p>
|
2003-02-01 14:21:27 +00:00
|
|
|
|
2003-10-13 13:08:52 +00:00
|
|
|
<p>Note that you cannot interact with the forked program, the only way
|
2003-12-08 02:27:14 +00:00
|
|
|
to send input to it is via the input and inputstring attributes. Also note that
|
2005-04-19 22:28:22 +00:00
|
|
|
since Ant 1.6, any attempt to read input in the forked program will receive an
|
2003-12-08 02:27:14 +00:00
|
|
|
EOF (-1). This is a change from Ant 1.5, where such an attempt would block.</p>
|
2003-10-13 13:08:52 +00:00
|
|
|
|
2008-07-16 15:56:12 +00:00
|
|
|
<p>If you want to execute an executable using a path relative to the
|
|
|
|
project's basedir, you may need to
|
|
|
|
use <code>vmlauncher="false"</code> on some operating systems - but
|
|
|
|
even this may fail (Solaris 8/9 has been reported as problematic).
|
|
|
|
The <code>resolveexecutable</code> attribute should be more
|
|
|
|
reliable, as would be something like
|
|
|
|
<pre>
|
|
|
|
<property name="executable-full-path"
|
|
|
|
location="../relative/path/to/executable"/>
|
|
|
|
<exec executable="${executable-full-path}" ...
|
|
|
|
</pre>
|
|
|
|
</p>
|
2004-11-05 08:58:09 +00:00
|
|
|
|
|
|
|
<h4>Windows Users</h4>
|
2004-11-19 09:07:12 +00:00
|
|
|
<p>The <code><exec></code> task delegates to <code>Runtime.exec</code> which in turn
|
2004-11-05 08:58:09 +00:00
|
|
|
apparently calls <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createprocess.asp">
|
|
|
|
<code>::CreateProcess</code></a>. It is the latter Win32 function that defines
|
|
|
|
the exact semantics of the call. In particular, if you do not put a file extension
|
|
|
|
on the executable, only ".EXE" files are looked for, not ".COM", ".CMD" or other file
|
|
|
|
types listed in the environment variable PATHEXT. That is only used by the shell.
|
|
|
|
</p>
|
2006-10-22 21:31:41 +00:00
|
|
|
<p>
|
|
|
|
Note that <em>.bat</em> files cannot in general by executed directly.
|
|
|
|
One normally needs to execute the command shell executable <code>cmd</code>
|
|
|
|
using the <code>/c</code> switch.
|
|
|
|
</p>
|
|
|
|
<blockquote>
|
|
|
|
<pre>
|
|
|
|
<target name="help">
|
|
|
|
<exec executable="cmd">
|
|
|
|
<arg value="/c"/>
|
|
|
|
<arg value="ant.bat"/>
|
|
|
|
<arg value="-p"/>
|
|
|
|
</exec>
|
|
|
|
</target>
|
|
|
|
</pre></blockquote>
|
2004-11-05 08:58:09 +00:00
|
|
|
|
2003-02-01 14:21:27 +00:00
|
|
|
<h4>Cygwin Users</h4>
|
2007-04-15 17:07:49 +00:00
|
|
|
<p>The <code><exec></code> task will not understand paths such as /bin/sh
|
|
|
|
for the executable parameter. This is because the Java VM in which Ant is
|
|
|
|
running is a standard Windows executable and is not aware of the Cygwin
|
|
|
|
environment (i.e., doesn't load <code>cygwin1.dll</code>). The only
|
|
|
|
work-around for this is to compile a JVM under Cygwin (at your own risk).
|
|
|
|
See for instance
|
|
|
|
<a href="http://java.sun.com/javase/6/docs/build/README-builds.html#cygwin">
|
|
|
|
sun jdk 6 build instructions for cygwin</a>.
|
2003-02-01 14:21:27 +00:00
|
|
|
</p>
|
2003-12-08 02:27:14 +00:00
|
|
|
|
2003-07-25 10:06:32 +00:00
|
|
|
<h4>OpenVMS Users</h4>
|
2003-08-01 10:08:12 +00:00
|
|
|
<p>The command specified using <code>executable</code> and
|
|
|
|
<code><arg></code> elements is executed exactly as specified
|
2003-09-25 12:36:19 +00:00
|
|
|
inside a temporary DCL script. This has some implications:
|
|
|
|
<ul>
|
|
|
|
<li>paths have to be written in VMS style</li>
|
|
|
|
<li>if your <code>executable</code> points to a DCL script remember to
|
|
|
|
prefix it with an <code>@</code>-sign
|
|
|
|
(e.g. <code>executable="@[FOO]BAR.COM"</code>), just as you would in a
|
|
|
|
DCL script</li>
|
|
|
|
</ul>
|
|
|
|
For <code><exec></code> to work in an environment with a Java VM
|
|
|
|
older than version 1.4.1-2 it is also <i>required</i> that the logical
|
|
|
|
<code>JAVA$FORK_SUPPORT_CHDIR</code> is set to <code>TRUE</code> in
|
|
|
|
the job table (see the <i>JDK Release Notes</i>).</p>
|
|
|
|
|
2003-08-01 10:08:12 +00:00
|
|
|
<p>Please note that the Java VM provided by HP doesn't follow OpenVMS'
|
|
|
|
conventions of exit codes. If you run a Java VM with this task, the
|
2005-03-30 17:08:27 +00:00
|
|
|
task may falsely claim that an error occurred (or silently ignore an
|
2003-08-01 10:08:12 +00:00
|
|
|
error). Don't use this task to run <code>JAVA.EXE</code>, use a
|
|
|
|
<code><java></code> task with the <code>fork</code> attribute
|
2003-09-25 12:36:19 +00:00
|
|
|
set to <code>true</code> instead as this task will follow the VM's
|
2003-08-01 10:08:12 +00:00
|
|
|
interpretation of exit codes.</p>
|
|
|
|
|
2004-04-13 10:36:42 +00:00
|
|
|
<h4>RedHat S/390 Users</h4>
|
|
|
|
|
|
|
|
<p>It has been <a
|
|
|
|
href="http://listserv.uark.edu/scripts/wa.exe?A1=ind0404&L=vmesa-l#33">reported
|
|
|
|
on the VMESA-LISTSERV</a> that shell scripts invoked via the Ant Exec
|
|
|
|
task must have their interpreter specified, i.e., the scripts must
|
|
|
|
start with something like:
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<pre>
|
|
|
|
#!/bin/bash
|
|
|
|
</pre>
|
|
|
|
</blockquote>
|
|
|
|
|
|
|
|
or the task will fail as follows:
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<pre>
|
|
|
|
[exec] Warning: UNIXProcess.forkAndExec native error: Exec format error
|
|
|
|
[exec] Result: 255
|
|
|
|
</pre>
|
|
|
|
</blockquote>
|
|
|
|
</p>
|
|
|
|
|
2008-07-18 13:09:30 +00:00
|
|
|
<h4><a name="background">Running Ant as a background process on
|
|
|
|
Unix(-like) systems</a></h4>
|
|
|
|
|
|
|
|
<p>If you run Ant as a background process (like <code>ant &</code>)
|
|
|
|
and use the <code><exec></code> task with <code>spawn</code>
|
|
|
|
set to <code>false</code>, you must provide explicit input to the
|
|
|
|
forked process or Ant will be suspended because it tries to read
|
|
|
|
from the standard input.</p>
|
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Parameters</h3>
|
|
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<td valign="top"><b>Attribute</b></td>
|
|
|
|
<td valign="top"><b>Description</b></td>
|
|
|
|
<td align="center" valign="top"><b>Required</b></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">command</td>
|
|
|
|
<td valign="top">the command to execute with all command line
|
|
|
|
arguments. <b>deprecated, use executable and nested
|
|
|
|
<code><arg></code> elements instead</b>.</td>
|
|
|
|
<td align="center" rowspan="2">Exactly one of the two.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">executable</td>
|
|
|
|
<td valign="top">the command to execute without any command line
|
2003-07-30 10:32:43 +00:00
|
|
|
arguments.</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">dir</td>
|
|
|
|
<td valign="top">the directory in which the command should be executed.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">os</td>
|
|
|
|
<td valign="top">list of Operating Systems on which the command may be
|
2001-07-06 15:11:29 +00:00
|
|
|
executed. If the current OS's name is contained in this list, the command will
|
|
|
|
be executed. The OS's name is determined by the Java Virtual machine and is set
|
2005-04-19 22:28:22 +00:00
|
|
|
in the "os.name" system property.
|
|
|
|
</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">osfamily</td>
|
|
|
|
<td valign="top">OS family as used in the <os> condition.
|
|
|
|
<em>since Ant 1.7</em></td>
|
2001-02-13 12:32:01 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
2003-07-28 10:39:31 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">spawn</td>
|
2005-04-29 18:58:16 +00:00
|
|
|
<td valign="top">whether or not you want the command to be spawned<br>
|
2003-07-28 10:39:31 +00:00
|
|
|
Default is false.<br>
|
2005-04-29 18:58:16 +00:00
|
|
|
If you spawn a command, its output will not be logged by ant.<br>
|
2003-09-19 08:44:22 +00:00
|
|
|
The input, output, error, and result property settings are not active when spawning a process.<br>
|
|
|
|
<em>since Ant 1.6</em>
|
2003-07-28 10:39:31 +00:00
|
|
|
</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
2001-02-13 12:32:01 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">output</td>
|
2003-12-08 02:27:14 +00:00
|
|
|
<td valign="top">Name of a file to which to write the output. If the error stream
|
2003-02-09 12:17:16 +00:00
|
|
|
is not also redirected to a file or property, it will appear in this output.</td>
|
2003-02-06 12:53:49 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">error</td>
|
2003-09-19 08:44:22 +00:00
|
|
|
<td valign="top">The file to which the standard error of the
|
|
|
|
command should be redirected. <em>since Ant 1.6</em></td>
|
2003-02-06 13:10:21 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">logError</td>
|
|
|
|
<td valign="top">This attribute is used when you wish to see error output in Ant's
|
2003-12-08 02:27:14 +00:00
|
|
|
log and you are redirecting output to a file/property. The error
|
|
|
|
output will not be included in the output file/property. If you
|
2003-02-06 13:10:21 +00:00
|
|
|
redirect error with the "error" or "errorProperty"
|
2003-09-19 08:44:22 +00:00
|
|
|
attributes, this will have no effect. <em>since Ant 1.6</em></td>
|
2001-02-13 12:32:01 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
2002-04-05 09:28:54 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">append</td>
|
2003-02-09 12:17:16 +00:00
|
|
|
<td valign="top">Whether output and error files should be appended to or overwritten.
|
2003-02-06 12:53:49 +00:00
|
|
|
Defaults to false.</td>
|
2002-04-05 09:28:54 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
2001-07-27 09:55:46 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">outputproperty</td>
|
2003-12-08 02:27:14 +00:00
|
|
|
<td valign="top">The name of a property in which the output of the
|
2003-02-06 12:53:49 +00:00
|
|
|
command should be stored. Unless the error stream is redirected to a separate
|
|
|
|
file or stream, this property will include the error output.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">errorproperty</td>
|
2003-12-08 02:27:14 +00:00
|
|
|
<td valign="top">The name of a property in which the standard error of the
|
2003-09-19 08:44:22 +00:00
|
|
|
command should be stored. <em>since Ant 1.6</em></td>
|
2001-07-27 09:55:46 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
2003-02-09 12:17:16 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">input</td>
|
|
|
|
<td valign="top">A file from which the executed command's standard input
|
|
|
|
is taken. This attribute is mutually exclusive with the
|
2003-09-19 08:44:22 +00:00
|
|
|
inputstring attribute. <em>since Ant 1.6</em></td>
|
2003-02-09 12:17:16 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">inputstring</td>
|
2003-12-08 02:27:14 +00:00
|
|
|
<td valign="top">A string which serves as the input stream for the
|
2003-02-09 12:17:16 +00:00
|
|
|
executed command. This attribute is mutually exclusive with the
|
2003-09-19 08:44:22 +00:00
|
|
|
input attribute. <em>since Ant 1.6</em></td>
|
2003-02-09 12:17:16 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
2001-11-27 19:44:46 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">resultproperty</td>
|
2003-12-08 02:27:14 +00:00
|
|
|
<td valign="top">the name of a property in which the return code of the
|
2003-07-25 10:06:32 +00:00
|
|
|
command should be stored. Only of interest if failonerror=false.</td>
|
2001-11-27 19:44:46 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
2001-02-13 12:32:01 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">timeout</td>
|
|
|
|
<td valign="top">Stop the command if it doesn't finish within the
|
|
|
|
specified time (given in milliseconds).</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">failonerror</td>
|
|
|
|
<td valign="top">Stop the buildprocess if the command exits with a
|
2003-07-25 10:06:32 +00:00
|
|
|
return code signaling failure. Defaults to false.</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-04-11 06:37:59 +00:00
|
|
|
<td valign="top">failifexecutionfails</td>
|
|
|
|
<td valign="top">Stop the build if we can't start the program.
|
|
|
|
Defaults to true. </td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr> <tr>
|
2001-02-13 12:32:01 +00:00
|
|
|
<td valign="top">newenvironment</td>
|
|
|
|
<td valign="top">Do not propagate old environment when new environment
|
|
|
|
variables are specified.</td>
|
|
|
|
<td align="center" valign="top">No, default is <i>false</i></td>
|
|
|
|
</tr>
|
2001-07-06 11:23:18 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">vmlauncher</td>
|
|
|
|
<td valign="top">Run command using the Java VM's execution facilities
|
|
|
|
where available. If set to false the underlying OS's shell,
|
|
|
|
either directly or through the antRun scripts, will be used.
|
|
|
|
Under some operating systems, this gives access to facilities
|
2001-11-20 06:51:57 +00:00
|
|
|
not normally available through the VM including, under Windows,
|
2001-07-06 11:23:18 +00:00
|
|
|
being able to execute scripts, rather than their associated
|
2002-06-22 23:38:38 +00:00
|
|
|
interpreter. If you want to specify the name of the
|
|
|
|
executable as a relative path to the directory given by the
|
|
|
|
dir attribute, it may become necessary to set vmlauncher to
|
|
|
|
false as well.</td>
|
2001-07-06 11:23:18 +00:00
|
|
|
<td align="center" valign="top">No, default is <i>true</i></td>
|
|
|
|
</tr>
|
2003-01-29 11:57:25 +00:00
|
|
|
<tr>
|
2004-09-10 15:16:11 +00:00
|
|
|
<td valign="top">resolveexecutable</td>
|
2003-01-29 11:57:25 +00:00
|
|
|
<td valign="top">When this attribute is true, the name of the executable
|
2004-09-10 15:16:11 +00:00
|
|
|
is resolved firstly against the project basedir and
|
2003-09-02 16:24:02 +00:00
|
|
|
if that does not exist, against the execution
|
2003-12-08 02:27:14 +00:00
|
|
|
directory if specified. On Unix systems, if you only
|
|
|
|
want to allow execution of commands in the user's path,
|
2003-09-19 08:44:22 +00:00
|
|
|
set this to false. <em>since Ant 1.6</em></td>
|
|
|
|
<td align="center" valign="top">No, default is <i>false</i></td>
|
2003-12-08 02:27:14 +00:00
|
|
|
</tr>
|
2004-09-10 15:16:11 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">searchpath</td>
|
2005-02-07 23:42:21 +00:00
|
|
|
<td valign="top">When this attribute is true, then
|
2004-09-10 15:16:11 +00:00
|
|
|
system path environment variables will
|
|
|
|
be searched when resolving the location
|
|
|
|
of the executable. <em>since Ant 1.6.3</em></td>
|
|
|
|
<td align="center" valign="top">No, default is <i>false</i></td>
|
|
|
|
</tr>
|
2001-02-13 12:32:01 +00:00
|
|
|
</table>
|
|
|
|
<h3>Examples</h3>
|
|
|
|
<blockquote>
|
|
|
|
<pre>
|
|
|
|
<exec dir="${src}" executable="cmd.exe" os="Windows 2000" output="dir.txt">
|
|
|
|
<arg line="/c dir"/>
|
|
|
|
</exec></pre>
|
|
|
|
</blockquote>
|
|
|
|
<h3>Parameters specified as nested elements</h3>
|
|
|
|
<h4>arg</h4>
|
|
|
|
<p>Command line arguments should be specified as nested
|
|
|
|
<code><arg></code> elements. See <a
|
|
|
|
href="../using.html#arg">Command line arguments</a>.</p>
|
|
|
|
<h4><a name="env">env</a></h4>
|
|
|
|
<p>It is possible to specify environment variables to pass to the
|
|
|
|
system command via nested <code><env></code> elements.</p>
|
|
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<td valign="top"><b>Attribute</b></td>
|
|
|
|
<td valign="top"><b>Description</b></td>
|
|
|
|
<td align="center" valign="top"><b>Required</b></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">key</td>
|
2006-09-17 00:23:56 +00:00
|
|
|
<td valign="top">
|
|
|
|
The name of the environment variable.
|
|
|
|
<br/>
|
|
|
|
<em>Note: (Since Ant 1.7)</em>
|
|
|
|
For windows, the name is case-insensitive.
|
|
|
|
</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
<td align="center" valign="top">Yes</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">value</td>
|
|
|
|
<td valign="top">The literal value for the environment variable.</td>
|
|
|
|
<td align="center" rowspan="3">Exactly one of these.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">path</td>
|
|
|
|
<td valign="top">The value for a PATH like environment
|
|
|
|
variable. You can use ; or : as path separators and Ant will
|
|
|
|
convert it to the platform's local conventions.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">file</td>
|
|
|
|
<td valign="top">The value for the environment variable. Will be
|
|
|
|
replaced by the absolute filename of the file by Ant.</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
2004-03-27 21:22:59 +00:00
|
|
|
<a name="redirector"><h4>redirector</h4></a>
|
|
|
|
<i><b>Since Ant 1.6.2</b></i>
|
|
|
|
<p>A nested <a href="../CoreTypes/redirector.html">I/O Redirector</a>
|
|
|
|
can be specified. In general, the attributes of the redirector behave
|
|
|
|
as the corresponding attributes available at the task level. The most
|
|
|
|
notable peculiarity stems from the retention of the <exec>
|
|
|
|
attributes for backwards compatibility. Any file mapping is done
|
|
|
|
using a <CODE>null</CODE> sourcefile; therefore not all
|
|
|
|
<a href="../CoreTypes/mapper.html">Mapper</a> types will return
|
|
|
|
results. When no results are returned, redirection specifications
|
|
|
|
will fall back to the task level attributes. In practice this means that
|
|
|
|
defaults can be specified for input, output, and error output files.
|
|
|
|
</p>
|
2002-04-11 06:37:59 +00:00
|
|
|
<h3>Errors and return codes</h3>
|
2004-11-19 09:07:12 +00:00
|
|
|
By default the return code of a <code><exec></code> is ignored; when you set
|
2003-07-25 10:06:32 +00:00
|
|
|
<code>failonerror="true"</code> then any return code signaling failure
|
|
|
|
(OS specific) causes the build to fail. Alternatively, you can set
|
|
|
|
<code>resultproperty</code> to the name of a property and have it assigned to
|
|
|
|
the result code (barring immutability, of course).
|
2002-04-11 06:37:59 +00:00
|
|
|
<p>
|
|
|
|
If the attempt to start the program fails with an OS dependent error code,
|
2004-11-19 09:07:12 +00:00
|
|
|
then <code><exec></code> halts the build unless <code>failifexecutionfails</code>
|
2003-07-25 10:06:32 +00:00
|
|
|
is set to <code>false</code>. You can use that to run a program if it exists, but
|
|
|
|
otherwise do nothing.
|
2002-04-11 06:37:59 +00:00
|
|
|
<p>
|
|
|
|
What do those error codes mean? Well, they are OS dependent. On Windows
|
2005-02-07 23:42:21 +00:00
|
|
|
boxes you have to look at
|
|
|
|
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes__0-499_.asp">
|
|
|
|
the documentation</a>; error code 2 means 'no such program', which usually means
|
|
|
|
it is not on the path. Any time you see such an error from any Ant task, it is
|
|
|
|
usually not an Ant bug, but some configuration problem on your machine.
|
2002-04-11 06:37:59 +00:00
|
|
|
|
|
|
|
<h3>Examples</h3>
|
2001-02-13 12:32:01 +00:00
|
|
|
<blockquote><pre>
|
2002-09-04 11:05:19 +00:00
|
|
|
<exec executable="emacs">
|
2001-02-13 12:32:01 +00:00
|
|
|
<env key="DISPLAY" value=":1.0"/>
|
|
|
|
</exec>
|
|
|
|
</pre></blockquote>
|
|
|
|
<p>starts <code>emacs</code> on display 1 of the X Window System.</p>
|
2003-09-06 15:48:01 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<blockquote><pre>
|
2004-12-21 14:58:33 +00:00
|
|
|
<property environment="env"/>
|
2001-02-13 12:32:01 +00:00
|
|
|
<exec ... >
|
2004-12-21 14:58:33 +00:00
|
|
|
<env key="PATH" path="${env.PATH}:${basedir}/bin"/>
|
2001-02-13 12:32:01 +00:00
|
|
|
</exec>
|
|
|
|
</pre></blockquote>
|
|
|
|
<p>adds <code>${basedir}/bin</code> to the <code>PATH</code> of the
|
|
|
|
system command.</p>
|
2003-09-06 15:48:01 +00:00
|
|
|
|
|
|
|
<blockquote><pre>
|
2005-02-07 23:42:21 +00:00
|
|
|
<property name="browser" location="C:/Program Files/Internet Explorer/iexplore.exe"/>
|
2003-09-06 15:48:01 +00:00
|
|
|
<property name="file" location="ant/docs/manual/index.html"/>
|
|
|
|
|
|
|
|
<exec executable="${browser}" spawn="true">
|
|
|
|
<arg value="${file}"/>
|
|
|
|
</exec>
|
|
|
|
</pre></blockquote>
|
|
|
|
<p>Starts the <i>${browser}</i> with the specified <i>${file}</i> and end the
|
2005-02-07 23:42:21 +00:00
|
|
|
Ant process. The browser will remain.</p>
|
2003-09-06 15:48:01 +00:00
|
|
|
|
2004-03-27 21:22:59 +00:00
|
|
|
<blockquote><pre>
|
|
|
|
<exec executable="cat">
|
|
|
|
<redirector outputproperty="redirector.out"
|
|
|
|
errorproperty="redirector.err"
|
|
|
|
inputstring="blah before blah">
|
|
|
|
<inputfilterchain>
|
2004-11-19 09:07:12 +00:00
|
|
|
<replacestring from="before" to="after"/>
|
2004-03-27 21:22:59 +00:00
|
|
|
</inputfilterchain>
|
2004-11-19 09:07:12 +00:00
|
|
|
<outputmapper type="merge" to="redirector.out"/>
|
|
|
|
<errormapper type="merge" to="redirector.err"/>
|
2004-03-27 21:22:59 +00:00
|
|
|
</redirector>
|
|
|
|
</exec>
|
|
|
|
</pre></blockquote>
|
|
|
|
|
|
|
|
Sends the string "blah before blah" to the "cat" executable,
|
|
|
|
using an <a href="../CoreTypes/filterchain.html"><inputfilterchain></a>
|
|
|
|
to replace "before" with "after" on the way in.
|
|
|
|
Output is sent to the file "redirector.out" and stored
|
|
|
|
in a property of the same name. Similarly, error output is sent to
|
|
|
|
a file and a property, both named "redirector.err".
|
|
|
|
|
2003-09-06 15:48:01 +00:00
|
|
|
|
2005-02-07 23:42:21 +00:00
|
|
|
<p><b>Note:</b> do not try to specify arguments using
|
|
|
|
a simple arg-element and separate them by spaces. This results in
|
|
|
|
only a single argument containing the entire string.</p>
|
2001-11-30 21:07:50 +00:00
|
|
|
<p>
|
2003-12-08 02:27:14 +00:00
|
|
|
<b>Timeouts: </b> If a timeout is specified, when it is reached the
|
2001-11-30 21:07:50 +00:00
|
|
|
sub process is killed and a message printed to the log. The return
|
|
|
|
value of the execution will be "-1", which will halt the build if
|
|
|
|
<tt>failonerror=true</tt>, but be ignored otherwise.
|
2004-03-27 21:22:59 +00:00
|
|
|
|
2006-09-11 04:33:25 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|