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.