ant Bootstrap Apache Ivy


Esempio

Aggiungi il seguente target nel tuo build.xml

<!-- Bootstrap ivy -->
<target name="ivy.bootstrap" description="Download Apache Ivy">

    <!-- Define the version to use -->
    <property name="ivy.version">2.4.0</property>

    <!-- Create directory if not exists -->
    <mkdir dir="${user.home}/.ant/lib" quiet="true" />

    <!-- Download it -->
    <echo message="Downloading Apache Ivy..." />
    <get dest="${user.home}/.ant/lib/ivy.jar" src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar" />
</target>

Dopo aver eseguito l'attività ant ivy.bootstrap , ora sarai in grado di risolvere le dipendenze usando apache edy.

<target name="ivy.resolve" description="Resolve all artifacts.">

    <!-- Define lib driectory -->
    <property name="dir.lib">lib</property>

    <!-- Create directory if not exists -->
    <mkdir dir="${dir.lib}" />

    <!-- Configure -->
    <property name="ivy.dep.file" value="ivy.xml" />
    <ivy:settings file="ivysettings.xml" />

    <!-- Retrieve to a defined pattern -->
    <echo message="Resolving dependencies..." />
    <ivy:retrieve pattern="${dir.lib}/[artifact](-[classifier]).[ext]" />
</target>

Definisci le tue risorse in ivy.xml

<ivy-module version="2.0">
        <info organisation="org.apache" module="java-build-tools"/>
        <dependencies>
                <dependency org="junit" name="junit" rev="4.11" />
                <dependency org="org.apache.commons" name="commons-compress" rev="1.9" />
        </dependencies>
</ivy-module>

E qualsiasi repository personalizzato in ivysettings.xml

<ivysettings>
    <settings defaultResolver="chain"/>
    <resolvers>
        <chain name="chain">
            <ibiblio name="central" m2compatible="true"/>
            <ibiblio name="github" m2compatible="true" root="http://github.com/"/>
        </chain>
    </resolvers>
</ivysettings>

Scarica le tue dipendenze eseguendo ant ivy.resolve .