ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Davidson" <>
Subject <exec/> troubles
Date Thu, 21 Oct 2004 16:15:12 GMT

I'm having a most puzzling problem with the <exec/> task.  What I am
failing to understand is: What directory is used as the base for
executing a command if the executable is specified relatively instead of

Take, for example, this very simple .. example:

	<?xml version="1.0"?>
	<project name="ant tests" default="build">
		<target name="build" description="Ant tests">
			<echo>Basedir is: ${basedir}</echo>
			<exec executable="${basedir}/Foo.exe" />

The (good) results I get are:

	Buildfile: D:\workspace\anttests\dirtest\a\build.xml
		 [echo] Basedir is: D:\workspace\anttests\dirtest\a
		 [exec] Hello world.
	Total time: 594 milliseconds

If, however, I leave out the ${basedir} from the <exec/> and specify

	<exec executable="Foo.exe" />

I get the following error:   (note that Foo.exe is in the same directory
as build.xml)

	Buildfile: D:\workspace\anttests\dirtest\a\build.xml
		 [echo] Basedir is: D:\workspace\anttests\dirtest\a
	BUILD FAILED: D:\workspace\anttests\dirtest\a\build.xml:6:
Execute failed: CreateProcess: Foo.exe error=2
	Total time: 516 milliseconds

Even specifying the dir= attribute doesn't help:

	<exec dir="${basedir}" executable="Foo.exe" />

gives the same error result.

I need to be able to specify the location of the executable relative to
the build.xml, not via an absolute path, because my build process is
running in a sandbox which could be checked out and run anywhere.

Is there something to this that I'm just not seeing?  The first cup of
coffee is down, but hasn't been absorbed yet, which may be contributing
to my obtuseness.

This electronic message transmission, including attachments, is for the exclusive use of the
individuals to which this e-mail is addressed and is to be reviewed and used exclusively for
authorized company purposes.  This transmission may contain proprietary, confidential or privileged
information.  If you are not the intended recipient of this transmission, you are hereby notified
that any use, copying, disclosure, dissemination, distribution or taking of any action in
reliance upon the contents of this transmission is strictly prohibited.  If you believe you
may have received this electronic message in error, please notify the sender immediately by
return email and delete or destroy the original message and/or any copy of it from your computer
system and/or your files.  Thank you. 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message