使用Ivy将多个工件发布到Maven存储库 [英] Publishing multiple artifacts to maven repository using ivy

查看:124
本文介绍了使用Ivy将多个工件发布到Maven存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用不同的ivy配置向maven存储库发布了组件的一些特性.例如,我采用了以下方式(常春藤文档)做同样的事情.

I published few atifacts of a component to a maven repository using different configurations of ivy. As an example, I took the following way (Ivy Documentation) to do the same..

<ivy-module version="1.0">
<info organisation="org.apache" module="filter"/>
<configurations>
<conf name="api"  description="only provide filter framework API"/>
<conf name="homemade-impl" extends="api" description="provide a home made implementation of our api"/>
</configurations>

<publications>
    <artifact name="filter-api" type="jar"  conf="api" ext="jar"/>
    <artifact name="filter-hmimpl" type="jar"  conf="homemade-impl" ext="jar"/>      
</publications>

</ivy-module>

根据上述配置,生成的工件为 filter-api.jar filter-hmimpl.jar ,并且我生成了一个pom文件 filter.pom 并将其发布到Maven存储库中.

According to the above configuration, the artifacts that are produced are filter-api.jar and filter-hmimpl.jar, and I generated a pom file filter.pom and published this into a maven repository.

现在,当我尝试使用以下方法解决另一个组件中的工件 filter-api 时.

Now, when I am trying to resolve the artifact filter-api in another component using the following..

    <dependency org="org.apache" name="filter" rev="3.1" conf="default->api"/>

但是它不起作用,我相信我的filter.pom应该包含一些这样的模块以使其起作用.

But it is not working, I believe my filter.pom should contain some modules like this, to make it work..

    <modules>
       <module>api</module> 
       <module>homemade-impl</module> 
    </modules>

我正确了吗,如果是的话,如何将不同的ivy conf映射到maven中的模块.

Am I correct, and if yes how can I map different conf's of ivy to modules in maven.

推荐答案

将多个文件发布到Maven存储库是棘手的,因为Maven模块通常只包含一个工件. Maven模块确实支持其他模块构件,这些构件在Maven依赖项中使用分类器"属性进行引用.

Publishing mutliple files to a Maven repository is tricky because Maven modules normally contain a single artifact. Maven modules do support additional module artifacts, which are referenced in a Maven dependency using the "classifier" attribute.

以下答案提供了将多个文件发布到Maven模块的示例:

The following answers provide examples of publishing multiple files to a Maven module:

  • how to publish 3rdparty artifacts with ivy and nexus
  • Convert ivy.xml to pom.xml

观察到ANT脚本正在使用 makepom 生成POM文件,并将这些文件视为已发布的工件(常春藤出版物部分的一部分).

Observe that the ANT scripts are using the makepom to generate POM files and that these files are considered artifacts published (part of the ivy publications section).

有关更多背景知识,您可能会对以下答案感兴趣,该答案涉及Maven范围"和常春藤配置"之间的差异.

For more background you might be interested in the following answer that deals with the differences between Maven "scopes" and ivy "confgurations".

最后,如果您的ivy版本使用配置,则可以配置

Finally, if your ivy build uses configurations, it's possible to configure the makepom task to map between configurations and scopes:

<ivy:makepom ivyfile="${build.dir}/ivy.xml" pomfile="${build.dir}/${ivy.module}.pom"/>
   <mapping conf="api" scope="compile"/>
</ivy:makepom>

这篇关于使用Ivy将多个工件发布到Maven存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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