离线/断开连接时解决Apache Ivy依赖关系?

时间:2012-03-09 05:31:13

标签: java ant ivy

离线/断开连接时,如何让Ivy解决本地缓存中的依赖关系(包括changing="true"的依赖关系?)

我正在开发一个基于Java的开源项目,该项目使用Apache Ivy来解析和下载第三方依赖项。该项目的build.xml有一个名为resolve的蚂蚁目标,下载常春藤(如果需要),然后使用常春藤来检索所需的罐子。

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

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

[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会在输出中打印以下行:

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

如何在离线时让Ivy从缓存中解析changing="true"个依赖关系,但在线时继续查询每个版本的存储库?

1 个答案:

答案 0 :(得分:12)

奥尔斯已回答了这个问题,但这并不明显。

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

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

来源: