Thursday, November 10, 2011

Ivy

We have used the log4j.jar in our project.We downloaded this jar manually.

A typical Java project can use hundreds of external jars. To expect to download these manually, tracking version numbers and all that can quickly become a harrowing experience.

Enter Ivy.

Ivy is a Ant extension - tell Ivy what jars you want, and it will do the downloading for you.

That sounds simple enough. But how does Ivy know where to download the jar from?

From a place called 'repositories'.

A repository is an online directory (location is http://repo1.maven.org/maven2) which contains ALL jars from all over the world.

Whenever Mr. John Whoever writes a new library john.jar, he uploads it to the repository. When you tell Ivy you need john.jar, Ivy downloads it from the repository.

If this sounds too easy, and you are not yet confused - let us learn some more things about repository.

After Ivy downloads the john.jar, it keeps a local copy of it in a local directory - by default in your home directory/.ivy/

This way, Ivy does not have to download from the online (central) repository each time - this makes builds go faster.

Second, http://repo1.maven.org/maven2 is a central repository really maintained by the 'Maven Project' - Maven is the competitor of Ant :)

Third, not every John likes to save his jar to Maven central repository - so there are other online repositories (jBoss has its own, SpringSource as well). So every once in a while you have to point Ivy to a different repository.

No comments: