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

查看:52
本文介绍了将 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 项目构建的 jars 发布到您的 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 构建的修改

ivy.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 中有一个分类器"属性,该属性设置为源"(非源).为方便起见,我们添加了 ivy 额外属性.
  • 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>

注意事项:

  • deliver 任务是可选的,但建议在您的 ivy 文件的情况下使用包含动态修订,例如latest.release"或latest.integration".
  • makepoms 任务对将 ivy 配置转换为 Maven 范围提供了强大的支持.不适用于您的情况,但可以鼓励您了解有关常春藤的更多信息:-)
  • publish 任务使用指定的模式来查找 ivy 中指定的文件出版物部分.
  • 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>

注意事项:

  • Ivy 下载使用配置的默认解析器 nexus-central.
  • ivy 发布任务推送到名为 nexus-deploy 的 Nexus 存储库
  • 此示例中的安全领域与 Nexus Maven 匹配.其他回购经理会有所不同.
  • Ivy downloads use the configured default resolver nexus-central.
  • The ivy publish task pushes to the Nexus repository called nexus-deploy
  • The security realm in this example matches Nexus Maven. Would be different for other repo managers.

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

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