Monday, January 11, 2010

How to convert a Maven pom.xml into an Ivy ivy.xml file

If you're using Maven just for resolving dependencies, Ivy might be a good alternative for you. You may convert your pom.xml into an ivy.xml file using the following Ant script:

<project name="convertPomToIvy" basedir="." default="convert"
xmlns:ivy="antlib:fr.jayasoft.ivy.ant"
xmlns:ac="antlib:net.sf.antcontrib">

<path id="antlib.classpath">
<fileset dir="C:/Program Files/apache-ivy-2.1.0" includes="*.jar"/>
<fileset dir="C:/Program Files/apache-ivy-2.1.0/lib" includes="*.jar"/>
</path>

<taskdef uri="antlib:fr.jayasoft.ivy.ant"
resource="fr/jayasoft/ivy/ant/antlib.xml"
classpathref="antlib.classpath"
loaderref="antlib.classpath.loader"/>

<target name="convert">
<ivy:convertpom pomFile="pom.xml" ivyFile="ivy.xml" />
</target>
</project>

Please note that you may want to adjust the paths to the Ivy JAR files.

2 comments:

Gabriele said...

will you provide newbies a demo project and instructions to see the script working in it?

stefan222 said...

Hi Gabriele,

I'm very sorry, but I don't have an example project at the moment. I did the Maven-2-Ivy transformation only once (for testing purposes) and published the essential part of it in my blog.

Best regards,
Stefan