Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resolving Apache Ivy dependencies when offline/disconnected?

Tags:

java

ant

ivy

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?

like image 349
Richard Hansen Avatar asked Mar 09 '12 05:03

Richard Hansen


1 Answers

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:

  • IVY-879
  • Ivy mailing list
like image 117
Mark O'Connor Avatar answered Oct 08 '22 06:10

Mark O'Connor