Resolving Apache Ivy dependencies when offline/disconnected?
Asked Answered
I

1

14

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

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.

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

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

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?

Inpour answered 9/3, 2012 at 5:31 Comment(5)
I gave an answer to that in this question: #6972017Foreleg
That's a second question. The first one has been answeredAsclepius
@Mark: You're right. I edited the question to remove the "how to conditionally set ivy.cache.ttl.default=eternal?" part because that is a separate issue. But my original question -- how to resolve dependencies when offline -- is still unanswered.Inpour
it sounds like changing and ttl cannot be used together, it might be a good idea to ask this question on the mailing listForeleg
This may be of interest: #53623140Ragen
T
13

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:

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

Sources:

Topazolite answered 9/3, 2012 at 8:6 Comment(4)
I hope you don't mind, I updated my answer with some of the information you gave here, to improve it.Foreleg
Thanks for the answer. Unfortunately, -Divy.cache.ttl.default=eternal doesn't work for me. Please see the updated question.Inpour
@RichardHansen It looks like your build is not caching as expected...Could you post up your ivy settings? When I tested my ivy build it worked offline without any special settings :-( (Also what version of ivy are you using?)Asclepius
I figured out why eternal didn't work: the dependency was marked changing="true". See updated question.Inpour

© 2022 - 2024 — McMap. All rights reserved.