2
votes

I have local filesystem Ivy repository and need to install (publish) all artifacts into remote Maven repository like Nexus or Artifactory. I wrote the ant script for ivy install task along the following lines:

<ivy:install 
    organisation="apache" 
    module="commons-lang" 
    revision="2.0" 
    from="ivyfilesys" to="remotemaven"/>

Now, there are multiple configurations in my local ivy repository (test, compile), these are declared in ivy.xml files that are present there. The local repository consists of two folders per artifact, jars and ivys. Jars folder contains jars and ivys folder contains ivy.xml with configurations declared inside. Also SHA and MD5 checksum files are present but nothing else.

I expected that Ivy will tell Maven repository about the available configurations but seems it does not. After I switch into the newly created repository for resolution, Ivy cannot find artifacts it has just installed there itself, claiming that test and compile configurations are missing.

Local repository is configured as file-based and artifacts can be resolved from there no problem. Remote repository is ibiblio, m2compatible:

<ibiblio name="remotemaven" m2compatible="true"
      root="http://my.server:8081/"
      pattern="[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>
/>

Root is configured to our server. Root and authentication are probably configured correctly as the installed artifacts appear on the server.

Is it a way to make Ivy to respect its own ivy.xml and install into Nexus or Artifactory repository with configurations, so it could later resolve them?

  • Maybe ivy:install task needs more options?
  • Maybe some configuration files missing or incomplete?
1

1 Answers

2
votes

Can ivy install and retrieve configurations from Maven repository?

The simple answer is no.

How ivy interprets a Maven repo

Maven does not support Ivy's concept of configurations. The closest comparison would be Maven "scopes". These are fixed and ivy's ibiblio resolver understands how to map these into configuration. The following answer has a more detailed description:

How ivy pushes file into a Maven repo

When publishing an artefact to Maven repository you must also generate the Maven metadata file: pom.xml. The makepom task allows you to specify which ivy configurations should be used for a particular Maven scope. The following answers might prove useful:

Ivy is not restricted to a fixed number of scopes. While ivy configurations are much more flexible, you cannot assume that each configuration is being use to populate standard project classpaths....

Bulk loading a Maven repo

So in conclusion to bulk transfer files from a local ivy repo to a Maven repository is not a trivial exercise for the following reasons:

  1. Translating ivy files into Maven POMs can be hard. Ivy's configurations do not work exactly the same as Maven scopes.
  2. Your local repository might contain files that are already in Maven Central and so don't really need to be explicitly uploaded.

In my experience the biggest problem is large numbers of 3rd party jars with no record of where they came from. To assist in Maven-izing new projects I developed a groovy script that uses the Nexus search API to find matching records in the Maven Central database. Generally speaking this approach results in a reduction in the number of jars to be locally stored by as much as 80%.

Hope this helps.