本文介绍了在离线/断开连接时解决 Apache Ivy 依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让 Ivy 在离线/断开连接时从本地缓存解析依赖项(包括具有 changed="true" 的依赖项)?

How can I get Ivy to resolve dependencies (including dependencies with changing="true") from the local cache when offline/disconnected?

我正在开发一个基于 Java 的开源项目,该项目使用 Apache Ivy 来解析和下载 3rd 方依赖项.项目的 build.xml 有一个名为 resolve 的 ant 目标,它下载 Ivy(如果需要),然后使用 Ivy 检索所需的 jar.

I'm working on a Java-based open-source project that uses Apache Ivy to resolve and download 3rd party dependencies. The project's build.xml has an ant target named resolve that downloads Ivy (if needed) and then uses Ivy to retrieve the required jars.

在线时一切正常.但是,如果没有 Internet 访问权限,即使所需的 jar 文件位于本地 Ivy 缓存 (~/.ivy2/cache) 中,ant resolve 也会失败.看来 Ivy 正在尝试连接到 Maven 存储库以刷新 changed="true" 依赖项.

Everything works great when online. However, without Internet access, ant resolve fails even if the required jars are in the local Ivy cache (~/.ivy2/cache). It appears that Ivy is trying to connect to the Maven repository to refresh changing="true" dependencies.

我得到的错误类似于以下内容:

The error I get is similar to the following:

[ivy:retrieve] You probably access the destination server through a proxy server that is not well configured.
[ivy:retrieve] You probably access the destination server through a proxy server that is not well configured.
[ivy:retrieve]
[ivy:retrieve] :: problems summary ::
[ivy:retrieve] :::: WARNINGS
[ivy:retrieve]  Host repo.example.com not found. url=http://repo.example.com/exampleorg/examplename/examplerev/ivys/ivy.xml
[ivy:retrieve]  Host repo.example.com not found. url=http://repo.example.com/exampleorg/examplename/examplerev/jars/examplename.jar
[ivy:retrieve]          module not found: exampleorg#examplename;examplerev
[ivy:retrieve]  ==== local: tried
[ivy:retrieve]    ~/.ivy2/local/exampleorg/examplename/examplerev/ivys/ivy.xml
[ivy:retrieve]    -- artifact exampleorg#examplename;examplerev!examplename.jar:
[ivy:retrieve]    ~/.ivy2/local/exampleorg/examplename/examplerev/jars/examplename.jar
[ivy:retrieve]  ==== shared: tried
[ivy:retrieve]    ~/.ivy2/shared/exampleorg/examplename/examplerev/ivys/ivy.xml
[ivy:retrieve]    -- artifact exampleorg#examplename;examplerev!examplename.jar:
[ivy:retrieve]    ~/.ivy2/shared/exampleorg/examplename/examplerev/jars/examplename.jar
[ivy:retrieve]  ==== repo: tried
[ivy:retrieve]    http://repo.example.com/exampleorg/examplename/examplerev/ivys/ivy.xml
[ivy:retrieve]    -- artifact exampleorg#examplename;examplerev!examplename.jar:
[ivy:retrieve]    http://repo.example.com/exampleorg/examplename/examplerev/jars/examplename.jar
[ivy:retrieve]          ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]          ::          UNRESOLVED DEPENDENCIES         ::
[ivy:retrieve]          ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]          :: exampleorg#examplename;examplerev: not found
[ivy:retrieve]          ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]
[ivy:retrieve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS

BUILD FAILED
~/exampleproj/build.xml:123: impossible to resolve dependencies:
        resolve failed - see output for details

按照警告的建议运行 ant -verbose resolve 会在输出中打印以下行:

Running ant -verbose resolve as suggested by the warning prints the following line in the output:

[ivy:retrieve] don't use cache for exampleorg#examplename;examplerev: changing=true

如何让 Ivy 在离线时从缓存中解析 changed="true" 依赖项,但在线时继续查询每个构建的存储库?

How can I get Ivy to resolve changing="true" dependencies from the cache when offline, but continue to query the repository each build when online?

推荐答案

oers 已经回答了这个问题,但并不明显.

oers has answered the question, but it's not obvious.

尝试从命令行运行您的构建设置 ivy.cache.ttl.default 属性:

Try running your build setting the ivy.cache.ttl.default property from the command-line:

ant -Divy.cache.ttl.default=eternal build

来源:

这篇关于在离线/断开连接时解决 Apache Ivy 依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 05:43