You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jeff Davidson <Je...@rocketgaming.com> on 2004/10/21 18:15:12 UTC

troubles

Ant-users,

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
absolutely?

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" />
		</target>
	
	</project>

The (good) results I get are:

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

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

	<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
	build:
		 [echo] Basedir is: D:\workspace\anttests\dirtest\a
	BUILD FAILED: D:\workspace\anttests\dirtest\a\build.xml:6:
Execute failed: java.io.IOException: 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.

Regards,
~Jeff 
  
 
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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: troubles

Posted by Matt Benson <gu...@yahoo.com>.
--- Jeff Davidson <Je...@rocketgaming.com> wrote:
> 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
> absolutely?

Without rehashing your entire post, aside from the
possibility of specifying "${basedir}/Foo.exe" as you
have noted, you might be interested to know that in
CVS HEAD the <exec> task has a searchpath attribute
for use with the existing resolveexecutable attribute.
 Used with <presetdef>, this might be cute:

<presetdef name="foo">
  <exec executable="foo.exe"
        resolveexecutable="true"
        searchpath="true">
    <env key="PATH" value="${basedir}" />
  </exec>
</presetdef>

HTH,
Matt


		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org