- Apache IVY - Discussion
- Apache IVY - Useful Resources
- Apache IVY - Quick Guide
- Apache IVY - Public Repository
- Apache IVY - Shared Repository
- Apache IVY - Local Repository
- Apache IVY - Resolvers
- Apache IVY - info
- Apache IVY - publish
- Apache IVY - cachepath
- Apache IVY - retrieve
- Apache IVY - install
- Apache IVY - resolve
- Apache IVY - Eclipse Ivy Plugin
- Apache IVY - Settings File
- Apache IVY - Terminology
- Apache IVY - Environment Setup
- Apache IVY - Overview
- Apache IVY - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Apache IVY - Cachepath Task
cachepath task is used to create an ANT classpath with resolved artifacts present in the cache. As ANT needs jars to be classpath to compile java files, Ivy cachepath builds the classpath.
Let s create Tester.java, build.xml and ivy.xml as described in
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:cachepath pathid="new.classpath" /> </target> <target name="compile" depends="resolve" description="Compile"> <mkdir dir="build/classes" /> <javac srcdir="src" destdir="build/classes"> <classpath refid="new.classpath" /> </javac> </target> </project>
Following are the important terms.
pathid − id of the classpath where cached jars are present.
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 compile
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 2314ms :: artifacts dl 15ms --------------------------------------------------------------------- | | modules || artifacts | | conf | number| search|dwnlded|evicted|| number|dwnlded| --------------------------------------------------------------------- | default | 2 | 2 | 0 | 0 || 4 | 0 | --------------------------------------------------------------------- compile: [javac] E:ivyuild.xml:13: warning: includeantruntime was not set, defau lting to build.sysclasspath=last; set to false for repeatable builds [javac] Compipng 1 source file to E:ivyuildclasses BUILD SUCCESSFUL Total time: 3 seconds
You can verify the compiled class file in project build directory.
Advertisements