can I turn off the .ivy cache all together?
Asked Answered
U

2

5

Is there a way to tell ant/ivy to not use a local $HOME/.ivy2 cache?

Upwind answered 16/2, 2011 at 17:2 Comment(3)
Same question twice from the same author. See #4935448Suiter
@MarkO'Connor - the other question asks about using a different location. This one asks about turning it off completely.Seamy
In that case it's answered here: #11079274Suiter
T
3

In the full book on ivy, you check out the "Setting up the repositories" section:

Several repositories use the same root in your filesystem. Referenced as ${ivy.default.ivy.user.dir}, this is by default the directory .ivy2 in your user home.

Note that several things can be done by setting Ivy variables.
To set them without defining your own ivysettings.xml file, you can:

  • set an Ant property before any call to Ivy in your build file if you use Ivy from Ant
  • set an environment variable if you use Ivy from the command line

For example:

<target name="resolve">
  <property name="ivy.default.ivy.user.dir" value="/path/to/ivy/user/dir"/>
  <ivy:resolve />
</target>

The packager resolver has also some settings to be configured to avoid ${home}:

<packager name="ivyroundup"
         buildRoot="/path/to/my/.ivy2/packager/build"
         resourceCache="/path/to/my/.ivy2/packager/cache"
         resourceURL="ftp://mirror.example.com/pub/resources/[organisation]/[module]/">
    <ivy pattern="http://ivyroundup.googlecode.com/svn/trunk/repo/modules/[organisation]/[module]/[revision]/ivy.xml"/>
    <artifact pattern="http://ivyroundup.googlecode.com/svn/trunk/repo/modules/[organisation]/[module]/[revision]/packager.xml"/>
</packager>
Tinstone answered 16/2, 2011 at 18:10 Comment(4)
I am not able to get the user.dir to be set. See posting at #4935448. As far as the packager resolver goes, where is this file please?Upwind
Don't be distracted by the packager resolver. It also performs caching but one assumes you're not using it.Suiter
Be careful when talking about "user.dir". One would naturally assume you're talking about the current working directory property set by the JVM. See download.oracle.com/javase/1.4.2/docs/api/java/lang/System.htmlSuiter
figured it out.. I just had to add that entry to my common.xml file and not to the build.xml files.Upwind
S
7

I'd create an ivysettings.xml file and specify the location of my cache using the caches directive:

<ivysettings>
    <settings defaultResolver="central"/>
    <caches defaultCacheDir="${ivy.settings.dir}/cache"/>
    <resolvers>
        <ibiblio name="central" m2compatible="true"/>
    </resolvers>
</ivysettings>

I think this more explicit and is less cryptic than setting the property ivy.default.ivy.user.dir within your build file.

Update

Using this approach the ivy cleancache task can be used to purge your nominated cache directory.

<target name="clean-all" depends="clean">
    <ivy:cleancache />
</target>
Serviceman answered 16/2, 2011 at 22:51 Comment(1)
That's what I am also using but I can't seem to be able to echo or otherwise access the configured cache location (as a property) from my Ant build.xml file.Scrappy
T
3

In the full book on ivy, you check out the "Setting up the repositories" section:

Several repositories use the same root in your filesystem. Referenced as ${ivy.default.ivy.user.dir}, this is by default the directory .ivy2 in your user home.

Note that several things can be done by setting Ivy variables.
To set them without defining your own ivysettings.xml file, you can:

  • set an Ant property before any call to Ivy in your build file if you use Ivy from Ant
  • set an environment variable if you use Ivy from the command line

For example:

<target name="resolve">
  <property name="ivy.default.ivy.user.dir" value="/path/to/ivy/user/dir"/>
  <ivy:resolve />
</target>

The packager resolver has also some settings to be configured to avoid ${home}:

<packager name="ivyroundup"
         buildRoot="/path/to/my/.ivy2/packager/build"
         resourceCache="/path/to/my/.ivy2/packager/cache"
         resourceURL="ftp://mirror.example.com/pub/resources/[organisation]/[module]/">
    <ivy pattern="http://ivyroundup.googlecode.com/svn/trunk/repo/modules/[organisation]/[module]/[revision]/ivy.xml"/>
    <artifact pattern="http://ivyroundup.googlecode.com/svn/trunk/repo/modules/[organisation]/[module]/[revision]/packager.xml"/>
</packager>
Tinstone answered 16/2, 2011 at 18:10 Comment(4)
I am not able to get the user.dir to be set. See posting at #4935448. As far as the packager resolver goes, where is this file please?Upwind
Don't be distracted by the packager resolver. It also performs caching but one assumes you're not using it.Suiter
Be careful when talking about "user.dir". One would naturally assume you're talking about the current working directory property set by the JVM. See download.oracle.com/javase/1.4.2/docs/api/java/lang/System.htmlSuiter
figured it out.. I just had to add that entry to my common.xml file and not to the build.xml files.Upwind

© 2022 - 2024 — McMap. All rights reserved.