Ivy Integration

Using Ivy for Dependency Resolution

Although Grails does not currently support Maven 1/2 it does come with support for dependency resolution (the main selling point of Maven) via Ivy.

Pre 1.0 Grails shipped Ivy as part of the core and to get started type the following from the root of your project:

grails install-ivy

Since 1.0 the Ivy integration is now a plug-in. To install Ivy do the following:

grails install-plugin ivy

Both commands, pre 1.0 and since 1.0, will create an ivy.xml and an ivyconf.xml. You can edit the ivy.xml to define your dependencies. For example:

<ivy-module version="1.0">
    <info organisation="codehaus" module="grails"/>
    <dependencies>
        <dependency org="apache" name="commons-lang" rev="2.1"/>
        <dependency org="apache" name="commons-cli" rev="1.0"/>
        <dependency org="apache" name="commons-beanutils" rev="1.7.0"/>
        <dependency org="apache" name="commons-collections" rev="3.2"/>
        <dependency org="apache" name="commons-logging" rev="1.1"/>
        <dependency org="apache" name="commons-pool" rev="1.2"/>
        <dependency org="apache" name="commons-validator" rev="1.3.0"/>
        <dependency org="dom4j" name="dom4j" rev="1.6.1"/>
        <dependency org="junit" name="junit" rev="3.8.1"/>		
    </dependencies>
</ivy-module>

Then when you run a Grails project the dependencies will be resolved first. If you want to add a local JAR repository you can change ivyconf.xml to add your local server. The default configuration resolves from Maven's ibiblio repository.

Whenever you wish to update your dependencies use:

grails get-dependencies
It is crappy and slow, but it's all that we have :)

1 Comment

  • Gravatar
    When I build a Grails project without Ivy (only "grails war"), the size is about 30 Megabytes. When I build it with "grails get-dependencies", then "grails war", the WAR size is about 44 Megabytes.

    Ivy downloads JARs in multple versions. For example, three versions of SL4J are inside my WEB-INF/lib folder after using the Ivy plugin.

    How can I find a remedy for this effect?

    Jun 01, 2009 03:06 AM mattes3

Post a Comment