Setting ivy home directory in Ant
Asked Answered
G

2

7

I would like to set the ivy.default.ivy.user.dir to something other than the default ${user.home}/.ivy2. I can do this on the command line with

ant -Divy.default.ivy.user.dir=${WORKSPACE}/IVYCACHE. But, I would like to have it set without a command line arg. I have tried setting this property in my build.xml, my common.xml and my ivysettings.xml. The strange thing is, that it seems to set the default cache to this path, but the verbose output says that there is no default setting for user.dir, so it uses the ${user.home}/.ivy2 path.

Here is the output when I set the user.dir in my build.xml file. Strangely, it sets the default cache to the path I used for user.dir

[ivy:buildlist] No ivy:settings found for the default reference 'ivy.instance'.  A default instance will be used
[ivy:buildlist] Loading jar:file:/usr/local/ant/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivy.properties
[ivy:buildlist] searching settings file: trying /home/hudson/.hudson/jobs/Next_CI/workspace/ivysettings.xml
[ivy:buildlist] searching settings file: trying /home/hudson/.hudson/jobs/Next_CI/workspace/ivyconf.xml
[ivy:buildlist] searching settings file: trying ivysettings.xml
[ivy:buildlist] searching settings file: trying ivyconf.xml
[ivy:buildlist] no settings file found, using default...
[ivy:buildlist] :: Ivy 2.2.0 - 20100923230623 :: http://ant.apache.org/ivy/ ::
[ivy:buildlist] jakarta commons httpclient not found: using jdk url handling
[ivy:buildlist] :: loading settings :: url = jar:file:/usr/local/ant/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
[ivy:buildlist] including url: jar:file:/usr/local/ant/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings-public.xml
[ivy:buildlist] no default cache defined: set to /home/hudson/.hudson/jobs/Next_CI/workspace/ivy2/cache
[ivy:buildlist] including url: jar:file:/usr/local/ant/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings-shared.xml
[ivy:buildlist] including url: jar:file:/usr/local/ant/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings-local.xml
[ivy:buildlist] including url: jar:file:/usr/local/ant/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings-main-chain.xml
[ivy:buildlist] including url: jar:file:/usr/local/ant/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings-default-chain.xml
[ivy:buildlist] settings loaded (71ms)
[ivy:buildlist]         default cache: /home/hudson/.hudson/jobs/Next_CI/workspace/ivy2/cache

Then later, it claims that user.dir is not set anywhere. resolve:

[ivy:resolve] Loading jar:file:/usr/local/ant/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivy.properties
[ivy:resolve] jakarta commons httpclient not found: using jdk url handling
[ivy:resolve] :: loading settings :: file = /home/hudson/.hudson/jobs/Next_CI/workspace/common/ivysettings.xml
[ivy:resolve] no default ivy user dir defined: set to /home/hudson/.ivy2

Here is my build.xml line:

<property name="ivy.default.ivy.user.dir" value="${basedir}/ivy2" />

I have tried adding this line to common/ivysettings.xml and common/common.xml with no luck.

Garner answered 8/2, 2011 at 15:29 Comment(1)
I think this question is now answered? You've asked it twice.... See #5020050Unlicensed
H
5

I added the exact line that you have specified in the sample build.xml provided in the ivy binary download and could see the artifacts downloaded in ivy2 subfolder within the samples folder.

...
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<property name="ivy.default.ivy.user.dir" value="${basedir}/ivy2" />
...

I am using ivy 2.2 and ant 1.8.2. Can you check if the same works for you?

[Edit]: From the docs,

Actually all ant properties are imported into ivy variables when the configuration is done (if you call ivy from ant). This means that if you define an ant property after the call to configure, it will not be available as an ivy variable.

Hertfordshire answered 9/2, 2011 at 5:50 Comment(6)
We are running ivy 2.2 and ant 1.8.1. Not sure what you mean about trying the line. I have put it in my top level build.xml file and it doesn't work. Maybe this is a bug in 1.8.1. I will try updating ant.Garner
tried ant 1.8.2 and still see no default user dir in the output and it doesn't put the stuff where I want it.Garner
I did try what you suggested using the sample build.xml file and of course it works. So, can someone give me a hint about why it fails in my build.xml?Garner
@user561638. Updated the answer with reference to docs, which could indicate a possible reason for your problemHertfordshire
still not getting this to work. I ran ant -d resolve >log.I see the user.dir get set correctly initially: Parsing buildfile jar.... Setting project property: ivy.default.ivy.user.dir -> /private/marlene_cote/training/root/IVY2CACHE But later during the ivy:resolve step, it sets it to the default:[ivy:resolve] setting 'ivy.default.ivy.user.dir' to '/home/marlene_cote/.ivy2' [ivy:resolve] setting 'ivy.home' to '/home/marlene_cote/.ivy2' [ivy:resolve] no default ivy user dir defined: set to /home/marlene_cote/.ivy2. Can anyone tell me why, please?Garner
I finally figured it out. I had to put the line in my common/common.xml file and nowhere else. Otherwise, I was stepping on my own settings.Garner
F
3

The environment variable ANT_OPTS allows to set jvm parameters. So you may put to your ANT_OPTS the same command line argument you invoke 'ant' shell script with. E.g. under m$ windoozer:

ANT_OPTS=-Divy.default.ivy.user.dir=C:/IVYCACHE
Formication answered 16/1, 2013 at 22:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.