要求“ivy:retrieve”的问题是,你还需要在ivy.xml上添加“artifact”标签。 (与URL公司完成),以收回在Maven存放处没有发现的扶养费。
出于两个原因,我不喜欢这样做。
- The ivy.xml should just declare your dependencies, not their locations.
- Need additonal custom logic in the build.xml to handle the 3rd party package
理想的情况是,决定如何下载各种词汇的存放场所,这就是为什么我喜欢 Pack。 即使我想要的图书馆不设在马文,我也能够召集集体处理。
The following is an example of changing the jreleaseinfo 进入集体依赖的项目(在来源地,我无法在马文找到)
ivy.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0">
<info organisation="com.myspotontheweb" module="ivy_packager"/>
<dependencies>
<dependency org="ch.oscg" name="jreleaseinfo" rev="1.3.0"/>
</dependencies>
</ivy-module>
宣布2名解决者。 Default is Maven2, the other is a Packager configuised to look local for Directive. (另见Ivy Roundup项目)
ivygings.xml
<ivysettings>
<settings defaultResolver="maven2"/>
<resolvers>
<ibiblio name="maven2" m2compatible="true"/>
<packager name="repackage" buildRoot="${user.home}/.ivy2/packager/build" resourceCache="${user.home}/.ivy2/packager/cache">
<ivy pattern="file:///${basedir}/repository/[organisation]/[module]/[revision]/ivy.xml"/>
<artifact pattern="file:///${basedir}/repository/[organisation]/[module]/[revision]/packager.xml"/>
</packager>
</resolvers>
<modules>
<module organisation="ch.oscg" name="jreleaseinfo" resolver="repackage"/>
</modules>
</ivysettings>
The magic is containing in the "packager" file. At resolve time this will be used to generate an ANT script that both downloads and extracts the required jars.
(No need to put this logic into your build.xml)
repository/ch.oscg/jreleaseinfo/1.3.0/ Packager.xml<>
<packager-module version="1.0">
<property name="name" value="${ivy.packager.module}"/>
<property name="version" value="${ivy.packager.revision}"/>
<property name="zipname" value="${name}-${version}"/>
<resource dest="archive" url="http://sourceforge.net/projects/jreleaseinfo/files/jreleaseinfo/jreleaseinfo%201.3.0/jreleaseinfo-1.3.0.zip/download" sha1="9386d92758e627d04c2480b820731fd538b13a3f" type="zip"/>
<build>
<move file="archive/${zipname}/${zipname}.jar" tofile="artifacts/jars/${name}.jar"/>
</build>
</packager-module>
为减少档案数量,我略去了该模块ivy.xml。 似乎可以选择,除非你要宣布它为许可,以及应当存在于公共存放处的其他属性。