让 ivy:retrieve 不将 jar 复制到两个配置中?
我正在尝试设置我的 ant 构建,以便运行 Ivy 函数的目标与持续构建和大多数开发人员运行的目标完全分开。我希望一个目标下载更新的依赖项,我将签入该依赖项。其他目标将通过包含相关目录中的 *.jar 来设置其类路径。
我有两个配置:
<configurations>
<conf name="compile" />
<conf name="test" />
</configurations>
我有一些依赖项:
<dependency
org="my.org"
name="some-lib"
rev="latest.release"
conf="compile->default" />
<dependency
org="my.org"
name="some-test-lib"
rev="latest.release"
conf="test->default" />
我使用 ivy:retrieve 下载这些依赖项及其传递依赖项:
<ivy:retrieve
pattern="lib/[conf]/[type]/[artifact]-[revision].[ext]"
sync="true"
file="ivy.xml" />
问题是我在编译目录和测试目录之间看到一些重复的 jar 文件,这些文件来自传递依赖项。由于我想签入所有这些 jar 并使用它们来创建类路径,因此我想避免重复。这可能吗?
lib/compile/jar/some-lib-1.0.jar
lib/compile/jar/slf4j-api-1.5.11.jar
lib/test/jar/some-test-lib-1.0.jar
lib/test/jar/junit-4.7.jar
lib/test/jar/slf4j-api-1.5.11.jar
I'm trying to set up my ant build so that the targets which run Ivy functions are completely separated from the ones that the continuous build and most developers run. I want one target to download updated dependencies, which I'll check in. Other targets will set up their classpath by including *.jar from the relevant directory.
I have two configurations:
<configurations>
<conf name="compile" />
<conf name="test" />
</configurations>
I have some dependencies:
<dependency
org="my.org"
name="some-lib"
rev="latest.release"
conf="compile->default" />
<dependency
org="my.org"
name="some-test-lib"
rev="latest.release"
conf="test->default" />
And I download those dependencies and their transitive dependencies using ivy:retrieve:
<ivy:retrieve
pattern="lib/[conf]/[type]/[artifact]-[revision].[ext]"
sync="true"
file="ivy.xml" />
The problem is that I'm seeing some duplicates jars between the compile and the test directories, which come from transitive dependencies. Since I want to check in all these jars and use them for creating classpaths, I'd like to avoid duplicates. Is this possible?
lib/compile/jar/some-lib-1.0.jar
lib/compile/jar/slf4j-api-1.5.11.jar
lib/test/jar/some-test-lib-1.0.jar
lib/test/jar/junit-4.7.jar
lib/test/jar/slf4j-api-1.5.11.jar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这不是重复,每个配置都是一组单独的 jar,并且 ivy restrieve 任务忠实地创建每个组......
也许直接创建类路径而不是填充一个类路径更有意义本地 lib 目录。
这是我的 ANT 构建文件的片段:
当我需要创建一组 jar 的本地副本(例如组装 Web 应用程序的目录)时,我通常只使用 ivy retrieve 任务:
更新
另一种选择是指示ivy在下载瞬态依赖项时排除slf4j模块,如下:
This is not duplication, each configuration is a separate set of jars and the ivy restrieve task is faithly creating each set....
Perhaps it would make more sense to create the classpaths directly, rather than populating a local lib directory.
Here's a snippet of my ANT build files:
I normally only use the ivy retrieve task when I need to create a local copy of a set of jars, for example assembling a web app's directory:
Update
Another alternative is to instruct ivy to exclude the slf4j module when downloading transient dependencies, as follows:
如果我能直接通过 Ivy 来做到这一点,那就最好了。现在我已经通过使用ant删除重复项解决了这个问题。
If I can do this through Ivy directly, that would be best. For now I've solved the problem by just deleting duplicates using ant.
尝试以下操作。你的测试应该扩展编译
如果我是对的,IVY 应该发现测试扩展了编译并且只会下载 slf4j 一次。
Try the following. Your test should extend compile
If i am right IVY should find that test extends compile and would download slf4j only once.