Convert ivy.xml to pom.xml

I have ivy.xml - https://gist.github.com/1898060 I also have a jar file associated with this ivy.xml. I need a mechanism to import this project into my maven repository and use it in my maven project. SO basically, if I can convert ivy.xml to pom.xml, I could make it work. Is there any mechanism by which I can achieve this? I am looking for something like a maven plugin to accomplish this task. I know that there are ways in which we can edit ivy.xml and build.xml to achieve this, but then I do not want to do this, since the project is in a private repo.

+8
java maven ivy
source share
2 answers

What you really need to do is publish the banks created by the ANT project to your Maven repository.

ant -Dproject.version=0.9.0-local-20120211095554 clean publish 

I know that you do not want to modify the construction of ANT, but creating an additional โ€œpublishingโ€ goal will integrate your ANT and Maven projects correctly.

The two jar artifacts published by your modified ANT construct can be used as follows:

 <dependency> <groupId>com.opengamma</groupId> <artifactId>og-analytics</artifactId> <version>0.9.0-local-20120211095554</version> </dependency> <dependency> <groupId>com.opengamma</groupId> <artifactId>og-analytics</artifactId> <version>0.9.0-local-20120211095554</version> <classifier>sources</classifier> </dependency> 

Changes to your ANT build

ivy.xml

Major changes relate to your publications section:

 <ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra"> <info organisation="com.opengamma" module="og-analytics"/> <publications> <artifact name="og-analytics" type="jar"/> <artifact name="og-analytics" type="pom"/> <artifact name="og-analytics" type="jar" e:classifier="sources"/> </publications> <dependencies> <dependency name="og-util" rev="0.9.0-local-20120211095525" revConstraint="latest.integration"/> <dependency org="org.jfree" name="jfreechart" rev="1.0.13"/> <dependency org="cern" name="colt" rev="1.2.0"/> <dependency org="cern" name="parallelcolt" rev="0.9.1"/> <dependency org="latexlet" name="latexlet" rev="1.11"/> <dependency org="org.apache.commons" name="commons-math" rev="2.1"/> <dependency org="it.dexy" name="json-doclet" rev="0.3.1"/> <dependency org="org.json" name="simple" rev="1.1"/> <exclude org="org.junit"/> </dependencies> </ivy-module> 

Notes:

  • ANT project will now publish 3 files, jar, jar sources and Maven POM
  • In Maven, source banks have classifier attributes that are set to Not source. To facilitate this, we add an additional ivy attribute.
  • There is no need for version and status information in the info tag header. This will be added by the publishing step.

build.xml

 <target name="prepare" description="Generate POM"> <fail message="Unset property: project.version" unless="project.version"/> <ivy:deliver deliverpattern="${build.dir}/ivy.xml" pubrevision="${project.version}" status="release"/> <ivy:makepom ivyfile="${build.dir}/ivy.xml" pomfile="${build.dir}/${ivy.module}.pom"/> </target> <target name="publish" depends="build,prepare" description="Upload to Nexus"> <ivy:publish resolver="nexus-deploy" pubrevision="${project.version}" overwrite="true" publishivy="false" > <artifacts pattern="${build.dir}/[artifact](-[classifier]).[ext]"/> </ivy:publish> </target> 

Notes:

  • The deliver task is optional, but recommended if your ivy file contains dynamic changes, such as "latest.release" or "latest.integration".
  • The makepoms task has powerful support for converting ivy configurations to the Maven area. Not applicable in your case, but an incentive to learn more about ivy :-)
  • The publish task uses the specified template to search for files specified in the ivy publications section.

ivysettings.xml

Here you configure the location of the repositories and credentials that will be used by the publication target.

 <ivysettings> <settings defaultResolver="nexus-central"/> <credentials host="somehost" realm="Sonatype Nexus Repository Manager" username="????" passwd="????"/> <resolvers> <ibiblio name="nexus-central" root="http://somehost/nexus/content/repositories/central/" m2compatible="true"/> <ibiblio name="nexus-deploy" root="http://somehost/nexus/content/repositories/repo" m2compatible="true"/> </resolvers> </ivysettings> 

Notes:

  • Ivy boot uses the configured default nexus-central.
  • The ivy publishing task pushes the Nexus repository called nexus-deploy
  • The security scope in this example is Nexus Maven. Will be different for other repo managers.
+16
source share

Apache Ant itself provides the task for this - makepom . Always helps to consult the documentation!

+3
source share

All Articles