English 中文(简体)
Apache IVY - retrieve
  • 时间:2024-09-17

Apache IVY - Retrieve Task


Previous Page Next Page  

retrieve task is used to resolve dependencies to a specified location in project workspace.

Let s create Tester.java, build.xml and ivy.xml as described in IVY - Resolve Task chapter.

Update the build.xml to use the ivy retrieve task.

build.xml


<project name="test" default="resolve" xmlns:ivy="antpb:org.apache.ivy.ant">
   <target name="resolve" description="resolve dependencies">
      <ivy:resolve />
      <ivy:retrieve sync="true" type="jar" />
   </target>
</project>

Following are the important terms.

    sync − sync true ensure that pb directory is up-to-date and any extra file gets deleted.

    type − type directs ivy to copy only specified type of artifacts pke jar. Source jar, javadoc jar will be ignored. type for source jar is src or source and doc or bundle for javadoc jar.

retrieve tasks copies the resolved dependencies in the pb directory of the project by default and can be changed using pattern attribute.

Building the project

As we ve all the files ready. Just go the console. Navigate to E: > ivy folder and run the ant command.


E:ivy > ant

Ivy will come into action, resolving the dependencies, you will see the following result.


Buildfile: E:ivyuild.xml

resolve:
[ivy:resolve] :: Apache Ivy 2.5.0 - 20191020104435 :: https://ant.apache.org/ivy
/ ::
[ivy:resolve] :: loading settings :: url = jar:file:/E:/Apache/apache-ant-1.9.14
/pb/ivy-2.5.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
[ivy:resolve] :: resolving dependencies :: com.tutorialspoint#test;working@Acer-
PC
[ivy:resolve]   confs: [default]
[ivy:resolve]   found commons-lang#commons-lang;2.6 in pubpc
[ivy:resolve]   found junit#junit;3.8.1 in pubpc
[ivy:resolve] :: resolution report :: resolve 316ms :: artifacts dl 18ms
      ---------------------------------------------------------------------
      |                  |            modules            ||   artifacts   |
      |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
      ---------------------------------------------------------------------
      |      default     |   2   |   2   |   0   |   0   ||   4   |   0   |
      ---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: com.tutorialspoint#test [sync]
[ivy:retrieve]  confs: [default]
[ivy:retrieve]  0 artifacts copied, 2 already retrieved (0kB/2756ms)

BUILD SUCCESSFUL
Total time: 31 seconds

You can verify the downloaded files in project pb directory.

Advertisements