需要將ivy與groovy插件結合使用。
的build.xml
<target name="resolve">
<ivy:resolve/>
<ivy:cachepath pathid="build.path" conf="build"/>
<ivy:cachefileset setid="jarfiles" conf="jars"/>
</target>
<target name="combine-jars" depends="resolve">
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>
<!--
Iterate thru each file expanding content into a temp directory
used to create a new jar
-->
<groovy>
project.references.jarfiles.each {
ant.unzip(src: it, dest:"build/tmp")
}
ant.jar(destfile:"build/newjar.jar", basedir:"build/tmp")
</groovy>
</target>
的ivy.xml
使用ivy配置,下載分成構建依賴關係和文件的集合 到構建內再把它們組合起來。
<ivy-module version="2.0">
<info organisation="org.myspotontheweb" module="demo"/>
<configurations>
<conf name="build" description="ANT tasks"/>
<conf name="jars" description="Files to be combined"/>
</configurations>
<dependencies>
<!-- build dependencies -->
<dependency org="org.codehaus.groovy" name="groovy-all" rev="1.8.2" conf="build->default"/>
<!-- jars dependencies -->
<dependency org="log4j" name="log4j" rev="1.2.16" conf="jars->default"/>
<dependency org="commons-lang" name="commons-lang" rev="2.6" conf="jars->default"/>
..
..
</dependencies>
</ivy-module>