2014-10-30 65 views
2

我想运行一个蚂蚁脚本,它被设置为执行各种php模块,例如从命令行使用蚂蚁的PHP文件 - windows

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

但是它与错误而失败“%1不是有效的Win32应用程序”

我这里描述的方法进行注册表调整... http://php.net/manual/en/install.windows.commandline.php

,并重复他们为phar。如果我打开一个命令窗口,只需输入它的名字即可执行php或phar文件,例如phploc.phar而不是完整的php.exe phploc.phar,但它不通过蚂蚁工作。

如果我改变蚂蚁文件:

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

一切工作正常,我想这是翻译成php.exe /build/tools/phploc.phar(或类似的东西)。

构建文件来自别人的项目,我通过git克隆,所以理想情况下我不想改变它。

所以我想我不明白为什么它通过命令行工作(即识别.php .phar是可执行的),但不通过蚂蚁。有什么不同?

谢谢!

注意:我在一台正在使用作为构建服务器(jenkins)的windows计算机上安装了php独立版(无apache)。 PATH已更改为包含php dir。

回答

1

Windows * .bat文件必须通过cmd运行。将您的示例更改为:

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