我是Ivy的新手,并且非常简单地尝试了它,用于获取中央Maven存储库中可用的常用库,例如Guava和Gson:
<ivy-module version="2.0">
<info organisation="com.company" module="foobar"/>
<dependencies>
<dependency org="com.google.guava" name="guava" rev="10.0.1"/>
<dependency org="com.google.code.gson" name="gson" rev="2.0"/>
</dependencies>
</ivy-module>
Run Code Online (Sandbox Code Playgroud)
在Windows上,默认情况下,Ivy将其文件存储在%USERPROFILE%\.ivy2\cache\; 在Unix-y系统上,它们是在下载的$HOME/.ivy2/.
我想这是一个非常基本的问题:如何告诉Ivy下载二进制文件和源代码,并将二进制jar放在一个(任意)目录中,并将源jar放在另一个目录中?
例如,我希望Ivy将所有下载的二进制文件放入其中[project_home]/WebContent/WEB-INF/lib.
请注意,我使用Ivy via Ant,沿着以下行,而不是IDE插件.
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="ivy" default="resolve" >
<target name="resolve" description="retrieve dependencies with ivy">
<ivy:retrieve/>
</target>
<path id="ivy.lib.path">
<fileset dir="tools/buildlibs" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</project>
Run Code Online (Sandbox Code Playgroud) 我有以下常春藤文件:
<configurations defaultconfmapping="buildtime">
<conf name="buildtime" visibility="private" description="Libraries needed only for compilation" />
<conf name="runtime" description="Libraries only needed at runtime" />
<conf name="test" description="Libraries only needed for testing" />
</configurations>
<dependencies>
<dependency org="net.java.dev" name="jvyaml" rev="0.2.1" conf="runtime" />
<dependency org="org.apache.solr" name="solr-core" rev="3.6.0" conf="runtime" />
</dependencies>
Run Code Online (Sandbox Code Playgroud)
我有一个如下所示的ant检索任务:
<target name="retrieve-all" depends="resolve">
<ivy:retrieve pattern="lib/[conf]/[artifact]-[revision].[ext]" conf="*" />
</target>
Run Code Online (Sandbox Code Playgroud)
奇怪的是,所有solr依赖项都按照我的预期下载到lib/runtime中,但是jvyaml模块没有!它'解析',但不会下载到lib/runtime目录,除非我将依赖声明更改为:
<dependency org="net.java.dev" name="jvyaml" rev="0.2.1" conf="runtime->master" />
Run Code Online (Sandbox Code Playgroud)
什么是主配置,为什么需要拉jvyaml jar,但不是solr?
谢谢
我正在使用常春藤,我工作的公司有一些有趣的小常春藤和蚂蚁教程。
当在依赖项部分使用时,每个教程都有助于完全绕过箭头在 ivy 构建 xml 文件中的作用。
因此,鉴于此设置:
<configurations>
<conf name = "runtime" />
<conf name = "build-tests" extends="runtime" />
</configurations>
...
<dependencies>
...
<dependency org="blah" name="junit" rev="default" conf="build-tests->runtime"/>
<dependency org="blahblah" name="xmlutil" rev="default" conf="build-tests->testing"/>
<dependency org="blahblahblah" name="slf4j" rev="default" conf="build-tests->simple"/>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
每个依赖声明了什么?我认为 build-tests 已经扩展了运行时(来自配置声明),那么为什么依赖项 conf 重新声明了这一点?是需要吗?
在testing和simple未在的ivy.xml我宣布,他们是魔术和一个正式的声明之外存在吗?
谢谢!