将ivy.xml转换为pom.xml [英] Convert ivy.xml to pom.xml

查看:140
本文介绍了将ivy.xml转换为pom.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ivy.xml - https://gist.github.com/1898060
我还有与此ivy.xml相关的jar文件。
我需要的是一种将这个项目导入我的maven仓库并在我的maven项目中使用它的机制。
所以基本上如果我能够将ivy.xml转换为pom.xml,我或许可以让它工作。
是否有一些机制可以实现这一目标。
我正在寻找像maven插件这样的东西来完成这项任务。
我知道有很多方法我们可以编辑ivy.xml和build.xml来实现这个目标,但后来我不想这样做,因为项目是私人仓库。

I have a ivy.xml - https://gist.github.com/1898060 I also have the jar file related to this ivy.xml. What i need is a mechanism to import this project to my maven repo and use it in my maven project. SO basically if i am able to convert the ivy.xml to pom.xml , i might be able to get it work. Is there some mechanism through which i can achieve this. I am looking for something like a maven plugin to accomplish this task. I know that there are ways we can edit the ivy.xml and build.xml to achieve this but then i dont want to do it , as the project is in a private repo.

推荐答案

您真正需要做的是将ANT项目构建的罐子发布到您的Maven存储库中。

What you really need to do is publish the jars built by ANT project into your Maven repository.

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

我知道您不想更改ANT版本,但创建额外的发布目标将正确集成您的ANT和Maven项目。

I know you don't want to change the ANT build, but creating an extra "publish" target will properly integrate your ANT and Maven projects.

由修改后的ANT版本发布的两个jar工件可以正常使用,如下所示:

The two jar artifacts, published by your modified ANT build, could be consumed normally 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>



对ANT版本的修改



常春藤.xml



主要更改是您的出版物部分:

Modifications to your ANT build

ivy.xml

Main changes are 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> 

注意:


  • ANT项目现在将发布3个文件,jar,来源jar和Maven POM

  • 在Maven源jar中有一个分类器属性设置为sources(不是资源)。为方便起见,我们添加了常春藤额外属性

  • info 标记标题中不需要版本和状态信息。这将由发布步骤添加。

  • The ANT project will now publish 3 files, jar, sources jar and the Maven POM
  • In Maven source jars have a "classifier" attributes that is set to "sources" (Not source). To facilitate this we're adding an ivy extra attribute.
  • No need for version and status information in the info tag header. This will be added by the publication step.
<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>

注意:


  • 投放任务是可选的,但建议您使用常春藤文件包含动态修订,例如latest.release或latest.integration。

  • makepoms 任务强大支持将常春藤配置转换为Maven范围。不适用于您的情况,但有动机去了解更多关于常春藤: - )

  • 发布任务使用指定的模式查找常春藤出版物部分中指定的文件。

  • The deliver task is optional, but recommended in case your ivy file contains dynamic revisions, such as "latest.release" or "latest.integration".
  • The makepoms task has powerful support for convert ivy configurations into Maven scopes. Does not apply in your case, but an incentive to learn more about ivy :-)
  • The publish task uses a specified pattern to find files specified in ivy's publications section.

您可以在此处配置发布构建目标使用的存储库和凭据的位置。

This is where you configure the location of the repositories and credentials to be used by publish build 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>

注意:


  • 常春藤下载使用配置的默认解析程序 nexus-central

  • 常春藤发布任务推送到名为 nexus-deploy的Nexus存储库

  • 此示例中的安全领域与Nexus Maven相匹配。其他回购经理会有所不同。

这篇关于将ivy.xml转换为pom.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆