简体   繁体   English

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

[英]Resolving Apache Ivy dependencies when offline/disconnected?

How can I get Ivy to resolve dependencies (including dependencies with changing="true" ) from the local cache when offline/disconnected? 当脱机/断开连接时,如何让Ivy从本地缓存中解析依赖关系(包括使用changing="true"依赖关系)?

I'm working on a Java-based open-source project that uses Apache Ivy to resolve and download 3rd party dependencies. 我正在开发一个基于Java的开源项目,该项目使用Apache Ivy来解析和下载第三方依赖项。 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. 项目的build.xml有一个名为resolve的ant目标,可以下载Ivy(如果需要),然后使用Ivy来检索所需的jar。

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 ). 但是,如果没有Internet访问,即使所需的jar文件位于本地Ivy缓存( ~/.ivy2/cache )中, ant resolve也会失败。 It appears that Ivy is trying to connect to the Maven repository to refresh changing="true" dependencies. 似乎Ivy正在尝试连接到Maven存储库以刷新changing="true"依赖项。

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

Running ant -verbose resolve as suggested by the warning prints the following line in the output: 按警告建议运行ant -verbose resolve在输出中打印以下行:

[ivy:retrieve] don't use cache for exampleorg#examplename;examplerev: changing=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? 如何在离线时让Ivy从缓存中解析changing="true"依赖关系,但是在线时继续查询每个构建的存储库?

oers has answered the question, but it's not obvious. 奥尔斯已回答了这个问题,但这并不明显。

Try running your build setting the ivy.cache.ttl.default property from the command-line: 尝试从命令行运行构建设置ivy.cache.ttl.default属性:

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

Sources: 资料来源:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM