How do I tell ivy4r to stay offline?
Asked Answered
A

1

2

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.

Applicatory answered 7/8, 2011 at 8:4 Comment(0)
A
8

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/>
Anonymous answered 8/8, 2011 at 6:55 Comment(5)
I hadn't searched in this direction. Will try it out and see what happens. Thanks!Applicatory
At first glance, this works. But we have changing artifacts. Any idea on how to not go to the network for them?Applicatory
Publish them to the local filesystem and retrieve from there by using the filesystem resolver.Anonymous
That's what we ended up doing. Based on the offline flag, we adjust the ivy4r settings to use a different resolver chain.Applicatory
For TTL to be in effect, don't forget to set your resolver's checkmodified attribute to false. I've spent hours trying to figure out why it's not working. See this for more details.Kohl

© 2022 - 2024 — McMap. All rights reserved.