如何没有错误执行git的Ant任务 [英] How to execute git ant task without errors
本文介绍了如何没有错误执行git的Ant任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创造了在Ant任务(build.xml文件)git的克隆小宏定义象下面这样:
I have created small macro definition for git clone in ant task(build.xml) like below:
<project name="MyProject" default="fileCopy">
<target name="fileCopy" depends="file-checks, local-file, git-file"/>
<target name="file-checks">
<available file="rdbms1.properties" property="file.found"/>
</target>
<target name="local-file" if="file.found">
<echo message="File is available in Local" />
</target>
<target name="git-file" unless="file.found">
<git command="clone" options="https://git-wip-us.apache.org/repos/asf/ant.git"/>
</target>
<macrodef name="git">
<attribute name="command" />
<attribute name="options" default="" />
<attribute name="dir" default="" />
<attribute name="failerror" default="false" />
<element name="args" optional="true" />
<sequential>
<echo message="git dir @{dir}" />
<echo message="git @{command}" />
<exec executable="git" dir="@{dir}" failonerror="@{failerror}">
<arg line="@{command} @{options}" />
<args />
</exec>
</sequential>
</macrodef>
</project>
但得到的异常象下面这样:
but getting exception like below:
C:\Users\Haritha\Desktop\H2H\conf\build.xml:14: The following error occurred while executing this line:
C:\Users\Haritha\Desktop\H2H\conf\build.xml:25: Execute failed: java.io.IOException: Cannot run program "git": CreateProcess error=2, The system cannot find the file specified
如何解决这一问题没有任何错误??成功地执行我的git Ant任务
How to solve this issue to execute my git ant task successfully without any errors??
推荐答案
添加git.exe的bin路径(类似于C:\\用户\\ Haritha \\桌面\\ git的\\ bin)添加到PATH变量如下图所示。为使其永久的改变,你可以,如果你使用的是Windows添加为环境变量。
Add bin path of git.exe (something like C:\Users\Haritha\Desktop\git\bin) to PATH variable like below. To make it permanent change, you could add it as environment variable if you are using Windows.
这篇关于如何没有错误执行git的Ant任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文