Skip to Content
Author's profile photo George Ushakov

Using Ivy for dependencies management in NWDS 7.3


The examples in this post are based on Ivy configuration files included in the distribution and omit original copyright information for readability. Ivy is distributed under Apache License, Version 2.0.

Ivy in NWDS

When working on Java projects which rely heavily on the use of third-party libraries and/or frameworks (like various Spring modules, for example) one need some dependency management mechanism to allow for quick and reliable resolution of required JAR dependencies.

The Java community has long favored the use of Maven repositories for just this purpose. Even though the Eclipse IDE, on which the NWDS is based, could very well be updated to handle Maven based projects, it might be a bit cumbersome to setup and to use together with the usual projects (Java, dynamic web, EAR) build with NWDS.

There is another way. Ivy is a flexible and unobtrusive dependency manager based on Ant, the scripting language NWDS understands by default. So this is how one  might use Ivy for a simple Spring project.

Configure Ivy project

Let’s assume that we want to use Spring’s Rest Template from Spring Data REST project to access a RESTful resource. For this we would need “spring-data-rest-webmvc.jar”, plus, possibly, a logging implementation, together with all required dependencies.

  • Download Ivy binary distribution and unzip in a temporary location.
  • Create a simple project in NWDS using “Genral” type.
  • Copy files “ivy.xml”, “ivy-2.4.0.jar”, “build.xml” to the location of the project (the actual version of the Ivy JAR may differ).
  • The project structure should look as following.


The “build.xml” file should be modified to contain the reference to the Ivy JAR and a slightly different target for retrieving the dependencies.

<project name="retrieve-ivy-deps" default="resolve-and-retrieve"  xmlns:ivy="antlib:org.apache.ivy.ant">
  <target name="init-ivy">
  <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant">
  <pathelement location="${basedir}/ivy-2.4.0.jar" />
  <target name="resolve-and-retrieve" depends="init-ivy" description="--> resolves dependencies declared in ivy.xml file">
  <delete dir="${basedir}/lib"/>
  <ivy:retrieve conf="compile"/>

The file “ivy.xml” is where the top-most artifacts needed for our project are declared. It specifies the “copmpile” configuration which will retrieve the artifacts themselves together with all required compile-time dependencies (as specified in the Maven repository).

<ivy-module version="1.0">
  <info organisation="some.organization" module="ivy-dependencies-manager" />
  <conf name="compile" description="jars required for compilation" />
  <dependency org="" name="spring-data-rest-webmvc" rev="2.1.6.RELEASE" conf="compile->default"/>
  <dependency org="ch.qos.logback" name="logback-classic" rev="1.1.7" conf="compile->default"/>

The remaining file, “ivysettings.xml” just tells Ivy that we want to use default Maven central repository.

  <settings defaultResolver="chain" />
  <chain name="chain">
  <ibiblio name="central" m2compatible="true"></ibiblio>

Once the “resolve-and-retrieve” target in the “build.xml” is executed (from contextual menu in the “Outline” view). All the needed dependencies for our project are resolved and downloaded into “lib” directory.

Buildfile: ivy~libs\build.xml
[ivy:retrieve] :: Apache Ivy 2.4.0 - 20141213170938 :: ::
[ivy:retrieve] :: loading settings :: file = ivy~libs\ivysettings.xml
[ivy:retrieve] :: resolving dependencies :: some.organization#ivy-dependencies-manager
[ivy:retrieve] confs: [compile]
[ivy:retrieve] found;2.1.6.RELEASE in central
[ivy:retrieve] found;2.1.6.RELEASE in central
[ivy:retrieve] found org.springframework#spring-tx;3.2.14.RELEASE in central
[ivy:retrieve] found org.springframework#spring-beans;3.2.14.RELEASE in central
[ivy:retrieve] found org.springframework#spring-core;3.2.14.RELEASE in central
[ivy:retrieve] found commons-logging#commons-logging;1.1.3 in central
[ivy:retrieve] found org.springframework.hateoas#spring-hateoas;0.16.0.RELEASE in central
[ivy:retrieve] found org.springframework#spring-aop;3.2.14.RELEASE in central
[ivy:retrieve] found aopalliance#aopalliance;1.0 in chain
[ivy:retrieve] found org.springframework#spring-context;3.2.14.RELEASE in central
[ivy:retrieve] found org.springframework#spring-expression;3.2.14.RELEASE in central
[ivy:retrieve] found org.springframework#spring-web;3.2.14.RELEASE in central
[ivy:retrieve] found org.springframework#spring-webmvc;3.2.14.RELEASE in central
[ivy:retrieve] found org.objenesis#objenesis;2.1 in central
[ivy:retrieve] found;1.8.6.RELEASE in central
[ivy:retrieve] found org.slf4j#slf4j-api;1.7.12 in central
[ivy:retrieve] found org.springframework.plugin#spring-plugin-core;1.1.0.RELEASE in central
[ivy:retrieve] found org.atteo#evo-inflector;1.2 in central
[ivy:retrieve] found com.fasterxml.jackson.core#jackson-annotations;2.3.3 in central
[ivy:retrieve] found org.slf4j#jcl-over-slf4j;1.7.12 in central
[ivy:retrieve] found com.fasterxml.jackson.core#jackson-databind;2.3.5 in central
[ivy:retrieve] found com.fasterxml.jackson.core#jackson-core;2.3.5 in central
[ivy:retrieve] found ch.qos.logback#logback-classic;1.1.7 in central
[ivy:retrieve] found ch.qos.logback#logback-core;1.1.7 in central
[ivy:retrieve] found org.slf4j#slf4j-api;1.7.20 in central
[ivy:retrieve] :: resolution report :: resolve 487ms :: artifacts dl 16ms
[ivy:retrieve] :: evicted modules:
[ivy:retrieve] org.slf4j#slf4j-api;1.7.7 by [org.slf4j#slf4j-api;1.7.12] in [compile]
[ivy:retrieve] org.slf4j#slf4j-api;1.7.12 by [org.slf4j#slf4j-api;1.7.20] in [compile]
[ivy:retrieve] org.slf4j#slf4j-api;1.7.6 by [org.slf4j#slf4j-api;1.7.12] in [compile]
[ivy:retrieve] com.fasterxml.jackson.core#jackson-annotations;2.3.0 by [com.fasterxml.jackson.core#jackson-annotations;2.3.3] in [compile]
  |                  |            modules            ||   artifacts   |
  |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
  |      compile     |   28  |   0   |   0   |   4   ||   24  |   0   |
[ivy:retrieve] :: retrieving :: some.organization#ivy-dependencies-manager
[ivy:retrieve] confs: [compile]
[ivy:retrieve] 24 artifacts copied, 0 already retrieved (7231kB/93ms)

Just for illustration, Ivy just resolved and made available for us a whole dependency tree of JARs. Here the same tree as viewed in Maven project in IntelliJ.


General remarks

The “ivy-libs” project created above can be reused for resolving the dependencies for any number of Java projects in the NWDS.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.