Search code examples
ivybuildr

How do I tell ivy4r to stay offline?


We recently switched from Ant to Buildr for building our projects. We use Ivy for dependency management, using the ivy4r Buildr extension. We have a local repository at the office which is used as a cache for public artifacts and in which we also publish our own artifacts.

Now for the problem: I'd like to be able to build my project when I do not have access to the office repository. Buildr has a flag to tell it to work offline (-o), but ivy4r does not seem to take this into account. Is there any way to make Ivy not try to download artifacts? I have them all available in the cache on my machine already.


Solution

  • Setting the cache timeout to eternal

    You can set the cache property ${ivy.cache.ttl.default} to eternal this will set the TTL: so that the repository will not be checked for new revisions.

    You could achieve this by calling ant with the following parameter:

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

    This is from the documentation:

    Defines a TTL (Time To Live) rule for resolved revision caching. When Ivy resolves a dynamic version constraint (like latest.integration or a version range), it can store the result of the resolution (like latest.integration=1.5.1) for a given time, called TTL. It means that Ivy will reuse this dynamic revision resolution result without accessing the repositories for the duration of the TTL, unless running resolve in refresh mode.

    ...

    The TTL duration can also be set to 'eternal', in which case once resolved the revision is always use, except when resolving in refresh mode.

    Other references:

    Setting UseCacheOnly for the resolve task

    The resolve task has the attribute useCacheOnly, which can be used to

    force[s] the resolvers to only use their caches and not their actual contents

    Example:

    <ivy:resolve file="path/to/ivy.xml" useCacheOnly="true/>