目前我有这样的配置:
的build.xml:
<!-- Ivy settings start-->
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
</condition>
<target name="download-ivy" unless="offline" description="Download Ivy">
<mkdir dir="${ivy.jar.dir}"/>
<!-- download Ivy from web site so that it can be used even without any special installation -->
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
</target>
<target name="init-ivy" depends="download-ivy" description="Initialize Ivy">
<!-- try to load ivy here from ivy home, in case the user has not already dropped
it into ant's lib dir (note that the latter copy will always take precedence).
We will not fail as long as local lib dir exists (it may be empty) and
ivy is in at least one of ant's lib dir or the local lib dir. -->
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>
<target name="update" depends="init-ivy" description="Download project dependencies">
<!-- edited for brevity -->
<ivy:retrieve pattern="war/WEB-INF/lib/[artifact]-[revision].[ext]" />
<!-- edited for brevity -->
</target>
<target name="clean-all" depends="clean" description="Purge ivy cache">
<ivy:cleancache/>
</target>
<!-- Ivy settings end-->
build.properties:
ivy.install.version=2.2.0
ivy.home=${user.home}/.ant
ivy.jar.dir=${ivy.home}/lib
ivy.jar.file=${ivy.jar.dir}/ivy-${ivy.install.version}.jar
的ivy.xml:
<ivy-module version="2.0">
<info organisation="org.apache" module="hello-ivy"/>
<dependencies>
<dependency org="commons-lang" name="commons-lang" rev="2.1" conf="default->master"/>
</dependencies>
</ivy-module>
这意味着Ivy将被下载到我的${user.home}/.ant/lib
并将从那里使用。
如何将其下载到我的项目库(例如war / WEB-INF / lib)并从那里使用它,所以我的所有文件都在一起,而不是分散在我的电脑周围?
答案 0 :(得分:4)
Ivy是ANT的插件。
使用替代目录是可能的,但是,您必须按如下方式运行ANT,以便ANT从其替代下载位置获取常春藤罐。
ant -lib $APP_DIR/lib .....
有关ANT如何管理插件库的详细信息,请参阅ANT manual。
附加说明:
Ivy将下载文件的缓存存储在以下目录 $ HOME / .ivy2 / cache 中。可以使用常春藤设置文件中的caches指令指定此目录的备用位置。