views:

1446

answers:

2

So this is the scenario. I have

<target name="test">
  <property file="blah"></property>
  <exec dir="" executable="trast.exe" resolveexecutable="true" spawn="true">
  </exec>
</target>     

<!-- So now I have the second target that uses Return value from first target -->
<target name="test2">
  <property file="blah"></property>
  <exec dir="" executable=RETURN VALUE resolveexecutable="true" spawn="true">
  </exec>
</target>

Basically I need a way to use the result from first target in the next target. I looked online and one solution seems to be is to parse output. But is there a way to get it without parsing?

Thanks

A: 

The first executable return the name of the executable that you later have to run in test2, right?

So the first executable could write that name into a script file (e.g. batch file on Windows, shell file on Unix). The script would have a fixed name and your Ant script would just run it.

Assaf Lavie
Well it is fixed.I just can not find way to access return value from target test in the target test2.
grobartn
Oh, I see, you mean test return the name of the exe that you want to execute?
Assaf Lavie
exactly ........
grobartn
+2  A: 

exec has a outputproperty. Could you do something like this:

<target name="test">
  <exec dir="" executable="trast.exe" resolveexecutable="true" spawn="true" outputproperty="blah">
  </exec>
</target>     

<!-- So now I have the second target that uses Return value from first target -->
<target name="test2">
  <exec dir="" executable="${blah}" resolveexecutable="true" spawn="true">
  </exec>
</target>

It's been awhile since I used ant and I don't have it installed on this machine but I seem to recall doing something like the above.

Or maybe resultproperty?

Found it here: http://ant.apache.org/manual/CoreTasks/exec.html

seth