Wednesday, July 1, 2009

Setting up Ivy

I got a nudge to look at Ivy again. Getting started was a little rough. Here is my experience:

I downloaded the latest Ivy, version 2.1.0-rc1. I copied the ivy jar file to my Ant lib directory per the installation instructions. Following the tutorial, I changed into the Ivy src/example/hello-ivy directory, and ran Ant:


$ ant
Buildfile: build.xml

resolve:
No ivy:settings found for the default reference 'ivy.instance'. A default instance will be used
no settings file found, using default...
[ivy:retrieve] :: Ivy 2.1.0-rc1 - 20090319213629 :: http://ant.apache.org/ivy/ ::
:: loading settings :: url = jar:file:/home/danson/apps/apache-ant-1.7.0/lib/ivy-2.1.0-rc1.jar!/org/apache/ivy/core/settings/ivysettings.xml
[ivy:retrieve] :: resolving dependencies :: org.apache#hello-ivy;working@danson-desktop
[ivy:retrieve] confs: [default]

BUILD FAILED
/home/danson/apps/apache-ivy-2.1.0-rc1/src/example/hello-ivy/build.xml:39: java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException



That's not encouraging. I googled for the error, and found people saying that the http client jar in Ant is the likely suspect. I'm running Ant 1.7.0, and I know Ant 1.7.1 was released a few days ago, so I installed it.


$ /home/danson/apps/apache-ant-1.7.1/bin/ant
Buildfile: build.xml

resolve:
No ivy:settings found for the default reference 'ivy.instance'. A default instance will be used
no settings file found, using default...
[ivy:retrieve] :: Ivy 2.1.0-rc1 - 20090319213629 :: http://ant.apache.org/ivy/ ::
:: loading settings :: url = jar:file:/home/danson/apps/apache-ant-1.7.1/lib/ivy-2.1.0-rc1.jar!/org/apache/ivy/core/settings/ivysettings.xml
[ivy:retrieve] :: resolving dependencies :: org.apache#hello-ivy;working@danson-desktop
[ivy:retrieve] confs: [default]
[ivy:retrieve] found commons-lang#commons-lang;2.0 in public
[ivy:retrieve] found commons-cli#commons-cli;1.0 in public
[ivy:retrieve] found commons-logging#commons-logging;1.0 in public
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.0/commons-lang-2.0-javadoc.jar ...
[ivy:retrieve] ............................................................................................................................................................................................................................................................................................................................................................... (467kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve] [SUCCESSFUL ] commons-lang#commons-lang;2.0!commons-lang.jar(javadoc) (1161ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.0/commons-lang-2.0-sources.jar ...
[ivy:retrieve] ......................................................................................................................................................................................... (245kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve] [SUCCESSFUL ] commons-lang#commons-lang;2.0!commons-lang.jar(source) (519ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.0/commons-lang-2.0.jar ...
[ivy:retrieve] .............................................................................................................................. (165kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve] [SUCCESSFUL ] commons-lang#commons-lang;2.0!commons-lang.jar (427ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-cli/commons-cli/1.0/commons-cli-1.0-javadoc.jar ...
[ivy:retrieve] ...................................................................... (92kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve] [SUCCESSFUL ] commons-cli#commons-cli;1.0!commons-cli.jar(javadoc) (352ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-cli/commons-cli/1.0/commons-cli-1.0-sources.jar ...
[ivy:retrieve] ..................................... (48kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve] [SUCCESSFUL ] commons-cli#commons-cli;1.0!commons-cli.jar(source) (298ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-cli/commons-cli/1.0/commons-cli-1.0.jar ...
[ivy:retrieve] ....................... (29kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve] [SUCCESSFUL ] commons-cli#commons-cli;1.0!commons-cli.jar (281ms)
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-logging/commons-logging/1.0/commons-logging-1.0.jar ...
[ivy:retrieve] .................. (21kB)
[ivy:retrieve] .. (0kB)
[ivy:retrieve] [SUCCESSFUL ] commons-logging#commons-logging;1.0!commons-logging.jar (275ms)
[ivy:retrieve] :: resolution report :: resolve 2162ms :: artifacts dl 3331ms
[ivy:retrieve] :: evicted modules:
[ivy:retrieve] commons-lang#commons-lang;1.0 by [commons-lang#commons-lang;2.0] in [default]
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 4 | 3 | 3 | 1 || 7 | 7 |
---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: org.apache#hello-ivy
[ivy:retrieve] confs: [default]
[ivy:retrieve] 7 artifacts copied, 0 already retrieved (1069kB/25ms)

run:
[mkdir] Created dir: /home/danson/apps/apache-ivy-2.1.0-rc1/src/example/hello-ivy/build
[javac] Compiling 1 source file to /home/danson/apps/apache-ivy-2.1.0-rc1/src/example/hello-ivy/build

BUILD FAILED
/home/danson/apps/apache-ivy-2.1.0-rc1/src/example/hello-ivy/build.xml:54: /home/danson/apps/apache-ivy-2.1.0-rc1/src/example/hello-ivy/lib not found.

Total time: 6 seconds



That's better, but still no joy.

I made a minor change to the build file to create the lib directory, then all was well:


<property name="lib.dir" value="lib">
<mkdir dir="${lib.dir}"> <!-- I added this line -->


$ ant
Buildfile: build.xml
[mkdir] Created dir: /home/danson/apps/apache-ivy-2.1.0-rc1/src/example/hello-ivy/lib

resolve:
No ivy:settings found for the default reference 'ivy.instance'. A default instance will be used
no settings file found, using default...
[ivy:retrieve] :: Ivy 2.1.0-rc1 - 20090319213629 :: http://ant.apache.org/ivy/ ::
:: loading settings :: url = jar:file:/home/danson/apps/apache-ant-1.7.0/lib/ivy-2.1.0-rc1.jar!/org/apache/ivy/core/settings/ivysettings.xml
[ivy:retrieve] :: resolving dependencies :: org.apache#hello-ivy;working@danson-desktop
[ivy:retrieve] confs: [default]
[ivy:retrieve] found commons-lang#commons-lang;2.0 in public
[ivy:retrieve] found commons-cli#commons-cli;1.0 in public
[ivy:retrieve] found commons-logging#commons-logging;1.0 in public
[ivy:retrieve] :: resolution report :: resolve 235ms :: artifacts dl 12ms
[ivy:retrieve] :: evicted modules:
[ivy:retrieve] commons-lang#commons-lang;1.0 by [commons-lang#commons-lang;2.0] in [default]
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 4 | 0 | 0 | 1 || 7 | 0 |
---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: org.apache#hello-ivy
[ivy:retrieve] confs: [default]
[ivy:retrieve] 7 artifacts copied, 0 already retrieved (1069kB/19ms)

run:
[javac] Compiling 1 source file to /home/danson/apps/apache-ivy-2.1.0-rc1/src/example/hello-ivy/build
[java] standard message : hello ivy !
[java] capitalized by org.apache.commons.lang.WordUtils : Hello Ivy !

BUILD SUCCESSFUL



I realized after I ran this and was successful, I'd used Ant 1.7.0 rather than 1.7.1. There is no need to download the files a second time since Ivy can tell it has the right files already, so I didn't run into the problem with the DecoderException.

So -- Ivy 2.1.0-rc1 needs Ant 1.7.1. Not a big deal, but it doesn't say that anywhere in the documentation.

1 comment:

Daniel Schneller said...

Hmmm... We are trying out Ivy at the moment as well and have no problems running it with Ant 1.6. Maybe there is something wrong with just 1.7.0?