Publishing multiple artifacts to maven repository using ivy

落花浮王杯 提交于 2019-11-27 08:15:28

问题


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>

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.

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"/>

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>

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


回答1:


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.

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

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).

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

  • How are maven scopes mapped to ivy configurations by 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>



回答2:


Most likely, the problem is with the dependency declaration. You pull the dependency into your 'default' configuration with conf="default->api". But you really want them in the "compile" conf, to include them in your compile classpath.



来源:https://stackoverflow.com/questions/14210381/publishing-multiple-artifacts-to-maven-repository-using-ivy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!