1

One of the 3rd party libraries used in my company is supplied to us as a zip file with tens of jars in it. The library releases a new version every two weeks, so I am looking for a solution that does not require a lot of manual effort each time a new release is out. I have recently started using Maven for dependency management and I have found it very difficult to deal with this particular 3rd party library. Should I...

  1. add each individual jar to a company-internal repository (e.g. with Nexus) and then declare each one of them as a dependency to any new projects using this library? This is a laborious process and I can't imagine doing this for every new release.

  2. create a jar of jars to add to our repository? If so, how do I create it? The Maven shade plugin would require that I mavenise the library first, right?

  3. any better suggestions?

Siato
  • 355
  • 1
  • 5
  • 13
  • In the past I've used artifactory and hosted my own maven repo, then scripted the deployment of the most annoying jar's / zips there. This way I can update my POM file and upload my new jars to the repo and all is well. – Mike McMahon Jun 26 '15 at 17:17

2 Answers2

3

Your first option is the best practice. I'm not sure why it should be laborious.

  1. create a simple script to upload the various jars to nexus
  2. use a property in your pom to specify the third-party version so all deps can be changed with a simple property change in the pom

Should be all of 5 minutes to add a new release to your build pipeline.

Alternative: convince the third-party to setup a maven repository for their customers to use!

jtahlborn
  • 52,909
  • 5
  • 76
  • 118
  • Since there is no control on the 3rd party zip, for each new version - you need to verify what versions have changed and if any new jar got added. – 6ton Jun 26 '15 at 17:27
  • @6ton that's exactly what I'm concerned about. The 3rd party library I'm using has a lot of jars and there is no guarantee that the very same versions will be used in later releases. – Siato Jun 26 '15 at 18:22
  • @jtahlborn Could you please give me some more details? For instance, step 1: to upload the various jars to Nexus, I need a group id, an artifact id and a version for each jar (e.g. for jetty8.3.jar, antlr3.4.0.jar etc.). Do I create dummy group ids etc or do I try to grab the version from the name (not always there)? If a new release of the software relies on jetty9.0.jar instead, do I not need to keep track of this and update my pom? Sorry if I have missed something. – Siato Jun 26 '15 at 18:35
  • @Thea - do you care about the original jar versions, or is the zip an entire "product" release? also, are those other jars the original jars (i.e. could you just use normal jetty from the central repo, or is the jar modified)? – jtahlborn Jun 26 '15 at 19:50
  • @jtahlborn The zip is an entire product, so I don't care about the specific jars. Obviously, some of the jars might have been downloaded from Maven Central, but there is no guarantee. The easiest way for me would be to have the entire library as one artifact without dependencies. I know this is not very Maven-esque but it's easier than having to upload each jar to Nexus every time there is a new relaase, or just keep track of which jars have changed with each release. If I decide to upload the entire library as one artifact, what is the best way of doing this? If not, what's the alternative? – Siato Jun 27 '15 at 08:32
  • @Thea - do you think the product still work correctly if you smash it together with onejar (or just shove all the classes into a single jar)? – jtahlborn Jun 28 '15 at 01:48
  • @jtahlborn I think it's going to work if it's all in one jar. I would prefer to put all classes in one jar as opposed to creating a jar of jars. Are there any tools for this or should I do it myself? – Siato Jun 28 '15 at 09:25
0

Its possible, but complicated (but only a 1 time effort) and probably a misuse of what maven's meant for:

  1. Upload zip file to your local maven repo with a specific groupid:artifactId
  2. Create a sub-module that has dependency on this zip file. Tis sub module should be used only for creating the uber jar
  3. Use maven-dependency-plugin unpack goal to unpack the zip file into a directory
  4. Use maven antrun unzip to unzip the jars to a dir
  5. Use maven antrun zip to jar the files into a uber jar
  6. Use maven-intall-plugin to install uber jar to your local repo and use as a dependency.
Community
  • 1
  • 1
6ton
  • 4,174
  • 1
  • 22
  • 37