views:

46

answers:

1

I am building a project using Ant and Ivy. The build.xml file depends on ant-contrib, bean scripting framework, beanshell, and commons-logging.

Ant searches for libraries in several places, including ${user.home}/.ant/lib.

Is there any way in the build.xml file to have these libraries automatically download and install in the ${user.home}/.ant/lib directory if they are not already present, perhaps using Ivy itself?

Thanks, Ralph

+1  A: 

The only jar you need in your ant lib is ivy :-)

Declare your dependencies as normal within your ivy.xml file. Make use of a configuration to collectively group the jars associated with ANT tasks:

<configurations>
    <conf name="tasks" description="Ant tasks"/>
</configurations>

<dependencies>
    <dependency org="ant-contrib" name="cpptasks" rev="1.0b5" conf="tasks->default"/>
    <dependency org="junit" name="junit" rev="3.8" conf="tasks->default"/>
    ..

In your build.xml file you can create a path from this configuration

<ivy:resolve/>
<ivy:cachepath pathid="tasks.path" conf="tasks"/>

<taskdef name="task1" classname="??" classpathref="tasks.path"/>
<taskdef name="task2" classname="??" classpathref="tasks.path"/>
Mark O'Connor