Reputation: 291
I'm trying to run an ant script which is set to execute various php modules e.g.
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="${basedir}/build/tools/phploc.phar">
<arg value="--count-tests" />
<arg path="${basedir}/src" />
<arg path="${basedir}/tests" />
</exec>
</target>
However it's failing with the error "%1 is not a valid Win32 application"
I've performed the registry tweaks as described here... http://php.net/manual/en/install.windows.commandline.php
and also repeated them for phar. If I open a command window I can execute a php or phar file just by typing it's name e.g. phploc.phar rather than the full php.exe phploc.phar however it's not working via ant.
If I change ant file to:
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="php">
<arg line="${basedir}/build/tools/phploc.phar --count-tests" />
<arg path="${basedir}/src" />
<arg path="${basedir}/tests" />
</exec>
</target>
everything works fine as I guess that's translated to php.exe /build/tools/phploc.phar
(or something like that).
The build file is from someone else's project which i've cloned via git so ideally I don't want to have to change it.
So I guess I don't understand why it's working via the commandline (i.e. recognising that .php .phar are executable) but not via ant. What's the difference?
Thanks!
NB: I have php installed standalone (no apache) on a windows machine being using as a build server (jenkins). PATH has been changed to include php dir.
Upvotes: 2
Views: 634
Reputation: 16365
Windows *.bat files have to be run thorugh the cmd
. Change your example to:
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="cmd">
<arg value="/c"/>
<arg value="${basedir}/build/tools/phploc"/>
<arg value="--count-tests" />
<arg path="${basedir}/src" />
<arg path="${basedir}/tests" />
</exec>
</target>
Upvotes: 1