在Ant中设置常春藤主目录

时间:2011-02-08 15:29:08

标签: ant properties ivy

我想将ivy.default.ivy.user.dir设置为默认${user.home}/.ivy2以外的其他内容。我可以在命令行中使用

执行此操作

ant -Divy.default.ivy.user.dir=${WORKSPACE}/IVYCACHE。但是,我想在没有命令行arg的情况下设置它。我尝试在build.xml,my.xml和myvysettings.xml中设置此属性。奇怪的是,它似乎将默认缓存设置为此路径,但是详细输出表明user.dir没有默认设置,因此它使用${user.home}/.ivy2路径。

这是我在build.xml文件中设置user.dir时的输出。 奇怪的是,它将默认缓存设置为我用于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

然后,它声称user.dir没有设置在任何地方。 解决:

[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

这是我的build.xml行:

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

我尝试将此行添加到common / ivysettings.xml和common / common.xml中,但没有运气。

2 个答案:

答案 0 :(得分:5)

我添加了您在常春藤二进制文件下载中提供的示例 build.xml中指定的确切行,并且可以看到ivy2子文件夹中samples子文件夹中下载的工件1}}文件夹。

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

我正在使用ivy 2.2和ant 1.8.2。你能检查一下是否适合你吗?

<强> [编辑]: 来自docs

  

实际上所有的蚂蚁属性都是   当导入到常春藤变量时   配置完成(如果你打电话给常春藤   来自蚂蚁)。这意味着,如果你   在调用之后定义一个ant属性   配置,它将无法使用   作为常春藤变量。

答案 1 :(得分:3)

环境变量ANT_OPTS允许设置jvm参数。所以你可以在你的ANT_OPTS中调用你调用'ant'shell脚本的相同命令行参数。例如。在m $ windoozer下:

ANT_OPTS=-Divy.default.ivy.user.dir=C:/IVYCACHE