Java 如何覆盖常春藤缓存的位置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1293113/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 07:52:14  来源:igfitidea点击:

How to override the location of Ivy's Cache?

javaivy

提问by Brett Rigby

I am using Ivy as part of my continuous integration build system, but I need to override the default location that Ivy's local cache area is.

我使用 Ivy 作为持续集成构建系统的一部分,但我需要覆盖 Ivy 本地缓存区域的默认位置。

采纳答案by Brett Rigby

Although the answer above from skaffman is correct, I found it to be a lot more work than I had expected!

虽然上面来自 skaffman 的答案是正确的,但我发现它比我预期的要多得多!

When I added the ivysettings.xml file to the project, I then needed to redefine almost everything, as the default values had been working fine until then.

当我将 ivysettings.xml 文件添加到项目中时,我需要重新定义几乎所有内容,因为在此之前默认值一直工作正常。

so, I found out how to add the new cache directory to the in-line command-line within my NAnt script...

所以,我发现了如何将新的缓存目录添加到我的 NAnt 脚本中的内嵌命令行中...

< exec program="java" commandline="... ... -jar ${ivy.jar} -cache ${project.cache} ... ... />

(Where ${ivy.jar}is the location of my .jar file and ${project.cache}is the new location set earlier in the script where I want the cache area to use.)

${ivy.jar}我的 .jar 文件${project.cache}的位置在哪里,是我希望缓存区域使用的脚本中前面设置的新位置。)

This means that I don't need the ivysettings.xml file, and I can revert everything back to using the default resolvers, etc.

这意味着我不需要 ivysettings.xml 文件,我可以将所有内容恢复为使用默认解析器等。

回答by skaffman

Something like this in ivysettings.xml:

像这样的东西ivysettings.xml

<ivysettings>
    <caches defaultCacheDir="/path/to/my/cache/dir"/>
</ivysettings>

See documentation at http://ant.apache.org/ivy/history/latest-milestone/settings/caches.html

请参阅http://ant.apache.org/ivy/history/latest-milestone/settings/caches.html 上的文档

回答by crazycode

I'm use Jenkins as CI build system, and create $HOME/.ivy2/ivysettings.xml:

我使用 Jenkins 作为 CI 构建系统,并创建 $HOME/.ivy2/ivysettings.xml:

<ivysettings>
    <properties environment="env" />
    <caches defaultCacheDir="${env.WORKSPACE}/.ivy2/cache" />
</ivysettings>

This create the ivy cache dir at each jenkins job's workspace.

这会在每个 jenkins 作业的工作区创建常春藤缓存目录。