Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过build.xml实现git拉取(ant任务)_Git_Ant_Build.xml - Fatal编程技术网

如何通过build.xml实现git拉取(ant任务)

如何通过build.xml实现git拉取(ant任务),git,ant,build.xml,Git,Ant,Build.xml,在这里,我试图从git中提取一个文件,如果它不在本地文件夹中,下面是我的代码 <?xml version="1.0" encoding="utf-8"?> <project name="MyProject" default="deploy"> <target name="deploy" depends="file-checks, local-file, git-file"/> <target name="file-checks">

在这里,我试图从git中提取一个文件,如果它不在本地文件夹中,下面是我的代码

<?xml version="1.0" encoding="utf-8"?>
<project name="MyProject" default="deploy">

    <target name="deploy" depends="file-checks, local-file, git-file"/>

    <target name="file-checks">
       <available file="C:\Users\Hareesh\Desktop\H2H\conf\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">
        <echo message="No" />
        <git command = "clone">
            <args>
                <arg value = "git://github.com/280north/ojunit.git" />
                <arg value = "ojunit" />
            </args>
        </git> 
    </target>
</project>
它显示以下错误:

Buildfile: C:\Users\Hareesh\Desktop\H2H\conf\build.xml
file-checks:
local-file:
git-file:
     [echo] No

BUILD FAILED
C:\Users\Hareesh\Desktop\H2H\conf\build.xml:15: Problem: failed to create task or type git
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.


Total time: 203 milliseconds
我遵循以下网址:


arg值是否有错误??我无法找到,因为我不了解git命令…请帮助我…提前感谢。

通过检查提供的链接,作者已将git定义为宏定义。因此,您需要在构建文件中包含这些定义,否则Ant将无法识别git是什么:


通过检查提供的链接,作者将git定义为macrodef。因此,您需要在构建文件中包含这些定义,否则Ant将无法识别git是什么:


好的,我可以直接将这个宏定义包含在git文件中吗target@HarithaR是的,您可以将macrodef包含在目标中,但将其添加为外部的顶级元素将使其对所有目标可见,以防其他目标也使用它。现在我已更正了我的方法并发送了正确的值,但它抛出了如下异常:C:\Users\Haritha\Desktop\H2H\conf\build.xml:23:目录C:\Users\Haritha\Desktop\H2H\conf\https:\github.com\libgit2\libgit2.git不存在,我正在发送输入https:\github.com\libgit2\libgit2.git,但windows路径正在添加,如何解决这个问题issue@HarithaR请在另一个问题中询问这个问题,指定更新的构建文件和确切的错误。好的,我可以直接将这个宏定义包含在git文件中吗target@HarithaR是的,您可以将宏定义包含在目标中,但将其添加为外部的顶级元素将使其对所有目标可见,以防其他目标也使用它。现在我已更正了我的方法并发送了正确的值,但它抛出了如下异常:C:\Users\Haritha\Desktop\H2H\conf\build.xml:23:目录C:\Users\Haritha\Desktop\H2H\conf\https:\github.com\libgit2\libgit2.git不存在,我正在发送输入https:\github.com\libgit2\libgit2.git,但windows路径正在添加,如何解决这个问题issue@HarithaR请在另一个问题中询问此问题,指定更新的构建文件和确切错误。
<macrodef name = "git">
    <attribute name = "command" />
    <attribute name = "dir" default = "" />
    <element name = "args" optional = "true" />
    <sequential>
        <echo message = "git @{command}" />
        <exec executable = "git" dir = "@{dir}">
            <arg value = "@{command}" />
            <args/>
        </exec>
    </sequential>
</macrodef>

<macrodef name = "git-clone-pull">
    <attribute name = "repository" />
    <attribute name = "dest" />
    <sequential>
        <git command = "clone">
            <args>
                <arg value = "@{repository}" />
                <arg value = "@{dest}" />
            </args>
        </git>
        <git command = "pull" dir = "@{dest}" />
    </sequential>
</macrodef>