Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute with Ant works with absolute path but not relative path

I have the following snippet in my Ant script. It executes just fine:

<exec executable="C:\test\foo\programName.exe" />

But then when I try to execute it by setting the directory, like so:

<exec executable="programName.exe"
  dir="C:\test\foo\" />

I get:

Execute failed: java.io.IOException: Cannot run program "programName.exe" (in directory "C:\test\foo"): CreateProcess error=2, The system cannot find the file specified

Please help! Why is it not working when the directory is specified separately?

like image 743
Cuga Avatar asked May 22 '09 21:05

Cuga


3 Answers

Add the resolveexecutable attribute:

<exec executable="programName.exe" 
  resolveexecutable="true"
  dir="C:\test\foo\" />

resolveexecutable When this attribute is true, the name of the executable is resolved firstly against the project basedir and if that does not exist, against the execution directory if specified. On Unix systems, if you only want to allow execution of commands in the user's path, set this to false. since Ant 1.6 No, default is false

like image 54
Mads Hansen Avatar answered Sep 22 '22 03:09

Mads Hansen


I ended up sticking with this:

<exec executable="${basedir}\myexefile.exe}" />
like image 42
Cuga Avatar answered Sep 24 '22 03:09

Cuga


Try this:

<property name="prog.dir" value="C:/test/foo" />
<exec executable="${prog.dir}/programName.exe"/>

It appears that the directory from which you execute the program must be in your build path.

like image 34
Jon Avatar answered Sep 24 '22 03:09

Jon