0

I am trying to understand how to manage this situation, suppose I have a 3rd party library (best-lib) that consists of three jars (a.jar, b.jar, c.jar) and I will be uploading those jars to a personal Artifactory server, the (best-lib) has two versions 1.0 and 2.0.

What I would like to have in my ivy.xml file is one single dependency to retrieve all those jars at once for example:

<dependencies>
    <dependency org="mycompany" name="best-lib" rev="1.0" />
</dependencies>

And this dependency should add all three jars (a, b, and c) of version 1.0.

The question is:

  1. Is this possible?
  2. How can I upload the three jars to artifactory to achieve this behaviour?
  3. Is it possible to upload those jars all at once?
  4. Artifactory alternative solutions are also acceptable (e.g. Nexus or Archivia).

Note: I am not building best-lib I just have its jars, and best-lib is not a library that can be downloaded from a public maven2 repository.

Thanks.

Omar Al Kababji
  • 1,768
  • 4
  • 16
  • 31

1 Answers1

2

When publishing the "best-lib" module, use an ivy.xml file that lists the 3 jars published by the module:

<ivy-module version="2.0">
    <info organisation="mycompany" module="best-lib"/>

    <publications>
        <artifact name="a" type="jar"/>
        <artifact name="b" type="jar"/>
        <artifact name="c" type="jar"/>
    </publications>
    ..
    ..

When you create a dependency against this module, ivy will understand that there are 3 jars in this module.

For an example of how to publish an ivy module see:

Update

If the 3 jars are already in your repository you could publish a stand-alone ivy modules that references the other 3 as dependencies:

<ivy-module version="2.0">
    <info organisation="mycompany" module="best-lib" rev="1.0"/>

    <dependences>
       <dependency org="mycompany" name="a" rev="1.0" />
       <dependency org="mycompany" name="b" rev="1.0" />
       <dependency org="mycompany" name="c" rev="1.0" />
    </dependencies>

Finally, you may need to tell us what format your Artifactory repository uses.... I have been assuming it's an ivy repo. If it's Maven then the concepts are the same but obviously server-side we'd be talking about pom.xml files, instead of ivy.xml (Ivy supports Maven repositories).

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • Thanks Mark, Is this the only way to accomplish it? are you aware if the same thing can be achieved using artifactory, maybe by uploading a zip file? – Omar Al Kababji Oct 14 '12 at 13:57
  • @OmarAlKababji I'm not an artifactory user, but I believe it supports publishing ivy repositories. An alternative approach is to publish your jars to a Maven repository (Artifactory can certainly support that repository format). In conclusion I would not recommend zip files.... That would be turned 3 files into a single artifact which could not be used without an extra unzip action.... – Mark O'Connor Oct 14 '12 at 14:46
  • @OmarAlKababji Are you just uploading the jars into Artifactory? Doesn't Artifactory have some sort of "upload" GUI functionality? – Mark O'Connor Oct 14 '12 at 14:48
  • Yes it has a UI to upload jars http://wiki.jfrog.org/confluence/display/RTF/Deploying+Via+the+Web+UI, Eihter individually where you specify the groupId, artifactId and the version. To upload several jars at once they provide uploading zip files. But I didn't understand how to be able to group all jars in that zip in such a way to get them back as a single dependency. – Omar Al Kababji Oct 14 '12 at 14:57
  • @OmarAlKababji The zip upload functionality appears to be a convenience. It assumes that the contents of the zip file are already in a Maven repository format. First choose your repository format. Then create a module that either contains all 3 artifacts or upload each artifact as a module and then create a fourth module that references the first 3 as dependencies. – Mark O'Connor Oct 14 '12 at 15:06
  • @OmarAlKababji The simplest way to get this done would be to upload each file as a Maven module in Artifactory. Then in your ivy file just create 3 dependencies. Ivy fully understands a Maven repository layout, so let Artifactory take care of if. If you truly want to integrate ivy and Maven the following posting has more details on how this stuff works.... In your case I reckon it's overkill: http://stackoverflow.com/questions/5111831/how-to-publish-3rdparty-artifacts-with-ivy-and-nexus/5115447#5115447 – Mark O'Connor Oct 14 '12 at 15:08