我有一个ivy.xml - https://gist.github.com/1898060 我还有与此ivy.xml相关的jar文件。 我需要的是一个机制,将这个项目导入我的maven仓库并在我的maven项目中使用它。 所以基本上如果我能够将ivy.xml转换为pom.xml,我可能能够让它工作。 是否有一些机制可以实现这一目标。 我正在寻找像maven插件这样的东西来完成这项任务。 我知道有一些方法可以编辑ivy.xml和build.xml来实现这一点,但后来我不想这样做,因为该项目是在私人仓库中。
答案 0 :(得分:17)
您真正需要做的是将ANT项目构建的jar发布到您的Maven存储库中。
ant -Dproject.version=0.9.0-local-20120211095554 clean publish
我知道您不想更改ANT版本,但创建额外的“发布”目标将正确集成您的ANT和Maven项目。
由修改后的ANT版本发布的两个jar工件可以正常使用,如下所示:
<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>
主要更改是您的出版物部分:
<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>
注意:
<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>
注意:
您可以在此处配置发布构建目标使用的存储库和凭据的位置。
<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>
注意:
答案 1 :(得分:3)
Apache Ant本身提供了执行此操作的任务 - makepom。总是有助于查阅文档!