Ant构建执行科尔多瓦 [英] Ant build executes cordova
问题描述
我创建一个Ant构建我的科尔多瓦项目如下:
I created an ant build for my cordova project as following:
<project default="build">
<target name="init-android">
<exec executable="cordova">
<arg value="platform"/>
<arg value="add"/>
<arg value="android"/>
</exec>
<exec executable="cordova">
<arg value="build"/>
</exec>
</target>
</project>
但我得到这个错误:
But I got this error:
C:\\ path_to_project \\ build.xml文件:3:执行失败:java.io.IOException异常:
无法运行程序科尔多瓦:CreateProcess的错误= 2,系统不能
找到指定的文件
在java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
在java.lang.Runtime.exec(Runtime.java:615)
在org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(JAV
a13CommandLauncher.java:41)
C:\path_to_project\build.xml:3: Execute failed: java.io.IOException: Cannot run program "cordova": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) at java.lang.Runtime.exec(Runtime.java:615) at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Jav a13CommandLauncher.java:41)
我可以从命令提示符没有问题的运行科尔多瓦命令,我有:
I can run cordova command with no problem from the command prompt, I have:
JAVA_HOME = C:/ Program Files文件/的Java / jdk1.7.0_10 /
ANT_HOME = C:\\ Program Files文件\\的Java \\ Apache的ANT-1.9.2
NODEJS_HOME = C:\\ Program Files文件\\的NodeJS
JAVA_HOME = C:/Program Files/Java/jdk1.7.0_10/ ANT_HOME = C:\Program Files\Java\apache-ant-1.9.2 NODEJS_HOME = C:\Program Files\nodejs
和他们都在我的道路。我不明白为什么它不工作。请帮忙。谢谢
and they are all in my path. I don't understand why it doesn't work. Please help. Thanks
推荐答案
一般用Java应用程序来启动程序在Windows中工作时,我经常要执行的cmd.exe
并通过它的完整路径程序其实我是想运行。这使得系统环境变量和这种要建立你所期望的方式。试试这个:
Generally when working with a Java application to launch programs in Windows, I often have to execute cmd.exe
and pass it the full path to the program I actually want to run. This allows system environment variables and such to be set up the way you expect. Try this:
<project default="build">
<target name="init-android">
<exec executable="cmd.exe">
<arg value="/C"/>
<arg value="cordova"/>
<arg value="platform"/>
<arg value="add"/>
<arg value="android"/>
</exec>
<exec executable="cmd.exe">
<arg value="/C"/>
<arg value="cordova"/>
<arg value="build"/>
</exec>
</target>
</project>
如果仍然无法正常工作,给予科尔多瓦的完整路径。如果你定义了一个环境变量应该工作。
If that still doesn't work, give the full path for cordova. An environment variable should work if you have one defined.
这篇关于Ant构建执行科尔多瓦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!