27

可能重复:
Ivy 无法解决依赖关系,无法找到原因

我正在尝试运行以下构建任务(initIvy):

<?xml version="1.0" encoding="UTF-8"?>
<project name="myproject-build" default="package" basedir=".." xmlns:ivy="antlib:org.apache.ivy.ant">
    <property file="build/build.properties"/>
    <property environment="env"/>

    <!-- Ant library path, including all of its plugins. -->
    <path id="ant.lib.path">
        <fileset dir="${env.ANT_HOME}/lib" includes="*.jar"/>
    </path>

    <!-- CONFIGURE IVY -->
        <taskdef resource="org/apache/ivy/ant/antlib.xml"
            uri="antlib:org.apache.ivy.ant" classpathref="ant.lib.path"/>

    <!-- Use Ivy tasks to resolve dependencies into the local Ivy cache. -->
    <target name="initIvy">
        <!-- Initialize Ivy and connect to host repository. -->
        <echo message="Initializing Apache Ivy and connecting to the host repository."/>
        <ivy:settings url="${ivy.std.repo.settings.url}" realm="${ivy.std.repo.realm}" username="${ivy.std.repo.username}" passwd="${ivy.std.repo.password}"/>

        <!-- Clear/flush the Ivy cache. -->
        <echo message="Cleaning the local Ivy cache for the current build."/>
        <ivy:cleancache/>
    </target>

    <!-- Rest of buildfile omitted for brevity. -->

</project>

当我运行时,ant -buildfile build.xml initIvy我得到以下输出:

Buildfile: /<path-to-my-project>/build/build.xml
    [taskdef] Could not load definitions from resource org/apache/ivy/ant/antlib.xml. It could not be found.

initIvy:
    [echo] Initializing Apache Ivy and connecting to the host repository.

BUILD FAILED
/<path-to-my-project>/build/build.xml:81: Problem: failed to create task or type antlib:org.apache.ivy.ant:settings
    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:
    -/<path-to-my-ANT_HOME>/lib
    -/home/myUser/.ant/lib
    -a directory added on the command line with the -lib argument

当我转到 ${ANT_HOME}/lib 时,我看不到任何标有“antlib*.jar”的 JAR。

所以我我下载了一个不包含 Antlib 的 Ant 版本,而现在我使用的是 Ivy(它使用 Antlib),构建过程是否令人窒息?

如果这是一个 Antlib 问题,那么我相信我想要一个可用的发行版here。如果是这样,有人可以确认我应该使用哪一个(仅包含 Antlib 而没有其他任何内容),并确认安装它的过程;即,是否就像将正确的 JAR 放入 ${ANT_HOME}/lib 一样简单?等等。

如果这是常春藤问题,那么有人可以为我指出正确的方向吗?

如果这既不是 Antlib 也不是 Ivy,同上上面的问题。提前致谢!

4

1 回答 1

66

我认为您可能缺少 Apache IVY 库。从这里下载 - apache ivy将 jar 复制到你的 ant lib 目录中。

例如(根据需要更改版本号):

  1. 下载并安装 Ant(例如C:\Apps\Tools\apache-ant-1.9.7)。
  2. 下载并解压 Ivy(例如,C:\Users\UserName\Downloads\apache-ivy-2.4.0
  3. 复制C:\Users\UserName\Downloads\apache-ivy-2.4.0\ivy-2.4.0.jarC:\Apps\Tools\apache-ant-1.9.7\lib.

Ant 配置为使用 Ivy。

于 2012-10-01T17:14:31.627 回答