开发者

How do I get and use the Apache Ivy.jar file from inside my project, without having it in my .ant folder?

At the moment I have this configuration:

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"/>
    <d开发者_Python百科ependencies>
        <dependency org="commons-lang" name="commons-lang" rev="2.1" conf="default->master"/>

    </dependencies>
</ivy-module>

This means that Ivy will be downloaded to my ${user.home}/.ant/lib and will be used from there.

How can I download it to my project library(for example war/WEB-INF/lib) and use it from there, so all my files are together and not scattered around my computer?


Ivy is a plug-in to ANT.

Using an alternative directory is possible, however, you'd have to run ANT as follows, in order for ANT to pick up the ivy jar from it's alternative download location.

ant -lib $APP_DIR/lib .....

See the ANT manual for details on how ANT manages plugin libraries.

Additional note:

Ivy stores a cache of downloaded files under the following directory $HOME/.ivy2/cache. Alternative locations for this directory can be specified using the caches directive in your ivy settings file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜