无法通过ANT运行phploc
我已经看过了这两篇文章。。他们没有帮助:无法通过ANT运行phploc,ant,jenkins,phploc,Ant,Jenkins,Phploc,我已经看过了这两篇文章。。他们没有帮助: 如果在shell提示符下运行phploc,它就可以正常工作。所以它一定是我的build.xml文件中的某个东西。。。但我不知道是什么 <target name="phploc" description="Measure project size using PHPLOC"> <exec executable="phploc"> <arg path="${basedir}/../src" />
build.xml
文件中的某个东西。。。但我不知道是什么
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="phploc">
<arg path="${basedir}/../src" />
<arg value="--log-csv" />
<arg value="${basedir}/build/logs/phploc.csv" />
</exec>
</target>
我的文件夹结构是
c:\projects\project1
build
...
vendor
bin
...
src
tests
c:\projects\project1\build>ant
phploc:
BUILD FAILED
C:\projects\project1\build\build.xml:55: Execute failed: java.io.IOException:
Cannot run program "phploc": CreateProcess error=2, The system cannot find the
file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Jav
更新
C:\>where phploc
INFO: Could not find files for the given pattern(s).
我遗漏了什么?从聊天讨论中发现,这是一个与路径相关的问题。这正是我所想的 在
中设置phploc
的绝对路径就成功了。它在C:\projects\project1\build目录下的命令行上工作,因为phploc
位于它的一个子目录(vendor\bin)中,并且该子目录已经位于PATH
变量中
PATH=C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Calibre2\;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Program Files (x86)\IDM Computer Solutions\UltraEdit\;C:\Program Files (x86)\Java;c:\ant\bin;.\vendor\bin
注意:虽然在这里提供绝对路径是可行的,但是使用相对路径是一个很好的实践,这样您的项目是可移植的。在这种情况下,您可以使用basedir作为所有相对路径的参考点。在命令提示下,键入:
where phploc
?请粘贴输出。您尝试过该命令吗?抱歉,正忙于其他事情。。。请给我一个小时左右的时间…C:\>其中phploc INFO:找不到给定模式的文件。您是否能够从此位置(即C:\)运行phploc?我的意思是,如果你在C:\,提供src文件夹的路径,它能工作吗?谢谢Technext。。。非常感谢。
PATH=C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Calibre2\;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Program Files (x86)\IDM Computer Solutions\UltraEdit\;C:\Program Files (x86)\Java;c:\ant\bin;.\vendor\bin