Apache IVY - Tâche d'installation

La tâche d'installation est utilisée pour installer un module et ses dépendances dans un résolveur. Il est utilisé lorsqu'un artefact public doit être téléchargé et utilisé dans un référentiel privé. Par défaut, un référentiel local utilisateur est son référentiel privé et est présent dans $ {ivy.default.ivy.user.dir} / local.

Créons Tester.java, build.xml et ivy.xml comme décrit dans chapitre .

Mettez à jour le fichier build.xml pour utiliser la tâche d'installation d'ivy.

build.xml

<project name="test" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">
   <target name="resolve" description="resolve dependencies">
      <ivy:resolve />
   </target>
   <target name="install" description="install dependencies">
      <ivy:install organisation="commons-lang" module="commons-lang" 
         revision="2.6" transitive="true" overwrite="false" 
         from="public" to="local" />
   </target>
</project>

Voici les termes importants.

  • organisation - nom de l'organisation.

  • module - nom du module du projet.

  • revision - version du projet.

  • from - du type de référentiel.

  • to - au type de référentiel.

Construire le projet

Comme nous avons tous les fichiers prêts. Allez simplement sur la console. Aller versE: > ivy dossier et exécutez la commande ant.

E:\ivy > ant install

Ivy entrera en action, résolvant les dépendances, vous verrez le résultat suivant.

E:\ivy > ant install
Buildfile: E:\ivy\build.xml

install:
[ivy:install] :: Apache Ivy 2.5.0 - 20191020104435 :: https://ant.apache.org/ivy
/ ::
[ivy:install] :: loading settings :: url = jar:file:/E:/Apache/apache-ant-1.9.14
/lib/ivy-2.5.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
[ivy:install] :: installing commons-lang#commons-lang;2.6 ::
[ivy:install] :: resolving dependencies ::
[ivy:install]   found commons-lang#commons-lang;2.6 in public
[ivy:install]   found junit#junit;3.8.1 in public
[ivy:install] :: downloading artifacts to cache ::
[ivy:install] :: installing in local ::
[ivy:install]   published commons-lang to C:\Users\Acer\.ivy2\local\commons-lang
\commons-lang\2.6.part\sources\commons-lang.jar
[ivy:install]   published commons-lang to C:\Users\Acer\.ivy2\local\commons-lang
\commons-lang\2.6.part\jars\commons-lang.jar
[ivy:install]   published commons-lang to C:\Users\Acer\.ivy2\local\commons-lang
\commons-lang\2.6.part\javadocs\commons-lang.jar
[ivy:install]   published ivy to C:\Users\Acer\.ivy2\local\commons-lang\commons-
lang\2.6.part\ivys\ivy.xml
[ivy:install]   publish committed: moved C:\Users\Acer\.ivy2\local\commons-lang\
commons-lang\2.6.part
[ivy:install]           to C:\Users\Acer\.ivy2\local\commons-lang\commons-lang\2
.6
[ivy:install]   published junit to C:\Users\Acer\.ivy2\local\junit\junit\3.8.1.p
art\jars\junit.jar
[ivy:install]   published ivy to C:\Users\Acer\.ivy2\local\junit\junit\3.8.1.par
t\ivys\ivy.xml
[ivy:install]   publish committed: moved C:\Users\Acer\.ivy2\local\junit\junit\3
.8.1.part
[ivy:install]           to C:\Users\Acer\.ivy2\local\junit\junit\3.8.1
[ivy:install] :: install resolution report ::
[ivy:install] :: resolution report :: resolve 0ms :: artifacts dl 21ms
      ---------------------------------------------------------------------
      |                  |            modules            ||   artifacts   |
      |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
      ---------------------------------------------------------------------
      |      default     |   2   |   0   |   0   |   0   ||   4   |   0   |
      ---------------------------------------------------------------------

BUILD SUCCESSFUL
Total time: 43 seconds

Vous pouvez vérifier les fichiers téléchargés dans l'emplacement du référentiel local par défaut d'ivy cache ${ivy.default.ivy.user.dir} > .ivy2 > local annuaire.