在常春藤中获得异常:配置任务

时间:2014-06-16 10:27:54

标签: ant teamcity ivy

我有以下常春藤:配置标签inmy build.xml如图所示

<target name="prepare" description="Ivy setting load">
            <echo message="Saral in Prepare"/>
            <delete dir="${project_dependencies}"/>
            <mkdir dir="${project_dependencies}"/>
            <path id="classpath">
                <fileset dir="lib">
                    <include name="${ops.dir}/ivy/ivy-2.3.0.jar"/>
                </fileset>
            </path>
            <ivy:configure file="${ops.dir}/ivy/ivysettings.xml" />
            <ivy:retrieve  type="jar" pattern="${project_dependencies}/[artifact].[ext]"/>
        </target>

....但是在运行构建时,我得到以下期望...请告诉我在build.xml中做了什么错误

[prepare] ivy:configure
[15:37:42]Problem: failed to create task or type ant lib:org.apache.ivy.ant:configure \
    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. \
    No types or tasks have been defined in this namespace yet  \
    This appears to be an antlib declaration. \
    Action: Check that the implementing library exists in one of: - \
    C:\TeamCity\buildAgent\plugins\ant\lib - \
    \\delfiler3.fm.rbsgrp.net\saxensl\MyGEOSProfile\FDR\.ant\lib \
    -a directory added on the command line with the -lib argument 
在build.xml中的

我已经开始如下..

<project name="abc" basedir="../." default="fulldist" 
    xmlns:ivy="antlib:org.apache.ivy.ant">

<!-- ivy task -->
    <path id="ivy.lib.path">
        <fileset dir="${lib.dir}" includes="*.jar"/>
    </path>
    <taskdef resource="org/apache/ivy/ant/antlib.xml">
        <classpath>
            <pathelement location="${ps.dir}/ivy/ivy-2.3.0.jar" />
        </classpath>
    </taskdef>

1 个答案:

答案 0 :(得分:0)

如果你想为常春藤任务使用NAMESPACE(以及推荐的那个),你需要<taskdef/>中的URI参数:

<project ... 
    xmlns:ivy="antlib:org.apache.ivy.ant">  <!-- Declares a namespace "ivy:"        -->

    <taskdef resource="org/apache/ivy/ant/antlib.xml"
        uri="antlib:org.apache.ivy.ant">    <!-- This was missing                   -->
                                            <!-- You need that to link your "ivy:"  -->
                                            <!-- Namespace to your XMLNS definition -->
                                            <!-- in the <project/> entity on top    -->
        <classpath>
            <pathelement location="${ps.dir}/ivy/ivy-2.3.0.jar" />
        </classpath>
    </taskdef>

URI字段将您的Ivy jar任务与您在build.xml顶部的XMLNS参数中声明的命名空间相关联。例如,您声明了一个名为ivy的XML名称空间,它与URI antlib:org.apache.ivy.ant相关联。现在,您必须在<taskdef/>中使用该URI将ivy:命名空间与任务定义相关联。

您不需要声明XML命名空间,但如果您不是<ivy:configure/>,则必须使用<configure/>作为任务名称。如果使用其他第三方Ant任务库,您可以看到这可能会导致问题。在Ivy中有<report/>任务,并且其他第三方ant任务库也可能有<report/>任务。通过为任务声明命名空间,可以消除此问题。