Ivy 无法解决依赖项,无法找到原因 [英] Ivy fails to resolve a dependency, unable to find cause

查看:33
本文介绍了Ivy 无法解决依赖项,无法找到原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 ivy:retrieve 时,它无法解析应下载的依赖项.输出如下所示:

While using ivy:retrieve, it fails to resolve the dependency that should be downloaded. The output looks like this:

Buildfile: C:\Users\Simon\workspace\apollo\build.xml
init:
resolve:

BUILD FAILED
C:\Users\Simon\workspace\apollo\build.xml:42: Problem: failed to create task or type antlib:org.apache.ivy.ant:retrieve
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:\Users\Simon\eclipse\plugins\org.apache.ant_1.8.2.v20120109-1030\lib
        -C:\Users\Simon\.ant\lib
        -a directory added on the command line with the -lib argument


Total time: 348 milliseconds

build.xml 的相关部分如下所示:

The relevant section of the build.xml looks like so:

  <target name="resolve" depends="init">
    <ivy:retrieve pattern="${lib}/[artifact]-[revision].[ext]" sync="true" />
  </target>

这里也是它应该下载的列表(来自 build.xml)

Here is also a list of what it should be downloading (from the build.xml)

  <target name="doc" depends="build">
    <javadoc sourcepath="${src}" classpathref="libraries" access="private" destdir="${doc}" windowtitle="Apollo">
      <doclet name="org.jboss.apiviz.APIviz" pathref="libraries">
        <param name="-sourceclasspath" value="${bin}" />
        <param name="-author" />
        <param name="-version" />
        <param name="-use" />
        <param name="-nopackagediagram" />
      </doclet>
      <doctitle><![CDATA[<h1>Apollo</h1>]]></doctitle>
      <link href="http://download.oracle.com/javase/6/docs/api/" />
      <link href="http://docs.jboss.org/netty/3.2/api/" />
      <link href="http://guava-libraries.googlecode.com/svn/trunk/javadoc/" />
      <link href="http://www.junit.org/apidocs/" />
      <link href="http://commons.apache.org/compress/apidocs/" />
      <link href="http://jruby.org/apidocs/" />
    </javadoc>
  </target>

推荐答案

ANT 找不到 ivy jar.需要下载,解压,并将ivy-xyzjar放入以下其中之一地点:

ANT cannot find the ivy jar. Needs to be downloaded, extracted, and the ivy-x.y.z.jar placed into one of the following locations:

  • $ANT_HOME/lib
  • $HOME/.ant/lib

Ivy 被打包为 antlib,因此要启用它,您需要执行以下操作

Ivy is packaged as an antlib, so to enable it you need to do the following

1)在构建文件的顶部声明ivy命名空间

1) Declare the ivy namespace at the top of the build file

<project ..... xmlns:ivy="antlib:org.apache.ivy.ant">

2)将 ivy jar 包含在 ant 库目录之一中

2) Include the ivy jar in one of the ant library directories

您的错误消息指出了 antlibs 的一些可能位置:

Your error message indictates some of the possible locations for antlibs:

This appears to be an antlib declaration. 
Action: Check that the implementing library exists in one of:
        -C:\Users\Simon\eclipse\plugins\org.apache.ant_1.8.2.v20120109-1030\lib
        -C:\Users\Simon\.ant\lib
        -a directory added on the command line with the -lib argument

注意:

antlib 的美妙之处在于你不需要执行 taskdef(如果你想将 ivy jar 放在非标准位置,它是可选的)

The beauty of an antlib is that you don't need to perform the taskdef (It's optional if you want to place the ivy jar in a non-standard location)

尽管ivy是一个ANT子项目,但由于一些莫名其妙的原因ivy没有和ANT一起打包......

Even though ivy is an ANT sub-project, for some inexplicable reason ivy is not packaged with ANT....

我通常在构建文件中包含以下目标以设置新环境:

I normally include the following target in my build files to setup a new environment:

<target name="bootstrap" description="Used to install the ivy task jar">
    <mkdir dir="${user.home}/.ant/lib"/>
    <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar"/>
</target>

它从 Maven Central 下载 ivy jar.

It downloads the ivy jar from Maven Central.

由于所有其他 ANT 任务随后都可以使用 ivy 下载,因此很少有人反对构建文件顶部的这一小块丑陋之处.

Since all other ANT tasks can subsequently be downloaded using ivy, few people object to this little piece of ugliness at the top of the build file.

这篇关于Ivy 无法解决依赖项,无法找到原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆