问题
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