Ivy

Steven J Zeil

Last modified: Nov 20, 2013

1. Why Ivy?

YAAP[1], Ivy adds the dependency management features pioneered by Maven to ant

Ivy Motivation and Features

2. Getting Started with Ivy

Start with an Ant Project

Again, let’s start with the Code Annotation project.

build.xml0.listing

Fetching Ivy

Start by having our build file actually load Ivy

build.xml1.listing

Specifying our Desired Libraries

We list the libraries our project needs in a separate ivy.xml file

<ivy-module version="2.0">
  <dependencies>
    <dependency org="de.jflex" name="jflex" rev="1.4.3"/>
    <dependency org="junit" name="junit" rev="4.10"/>
  </dependencies>
</ivy-module>

This should look familiar to the section from the Maven pom:

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  

Ivy is Often Simpler

Although the handling of Junit is similar, compare the handling of JFlex in Ivy:

<ivy-module version="2.0">
  <dependencies>
    <dependency org="de.jflex" name="jflex" rev="1.4.3"/>
    <dependency org="junit" name="junit" rev="4.10"/>
  </dependencies>
</ivy-module>

to Maven:

  <build>
    ⋮
    <pluginManagement>
    <plugins>
      <plugin>
        <groupId>de.jflex</groupId>
        <artifactId>maven-jflex-plugin</artifactId>
        <version>1.4.3</version>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </pluginManagement>
  </build>
  

Maven makes a distinction between simple library dependencies and plugins.

Invoking Ivy

Once Ivy is installed, we can invoke it:

build.xml2.listing

Set Up Classpaths

… to use the newly downloaded libraries.

build.xml3.listing


  1. Yet Another Apache Project  ↩