在脱机/断开连接时解决Apache Ivy依赖关系?

2022-09-04 21:27:57

如何让 Ivy 在脱机/断开连接时从本地缓存解析依赖关系(包括 与 ) 的依赖关系?changing="true"

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

在线时一切正常。但是,如果没有 Internet 访问,即使所需的 jar 位于本地 Ivy 缓存中,也会失败 ()。Ivy 似乎正在尝试连接到 Maven 存储库以刷新依赖项。ant resolve~/.ivy2/cachechanging="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

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

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

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

来源:


答案 2

推荐