0

My Java project depends on external jars, which are open source but aren't on Maven, and in fact are non-trivial to find on the web. I would like to make my project available in the Maven central repository, but obviously I can't just add those external jars as Maven dependencies. What is the best way to go about it?

I can see two possible solutions:

  1. Somehow package those external jars in with my own project, and tell users in an INSTALL message to first put the external jars in their own local repository

  2. Add those external jars to the Maven repository myself, under my own groupid but not touching them otherwise.

I'm not entirely sure whether the first is possible, or whether the second is ethical. Advice would be welcome.

Arend
  • 2,363
  • 1
  • 18
  • 18

1 Answers1

1

A third possibility would be to include the external JARs as part of your JAR.

You could try the Maven shade plugin to copy the classes into your JAR.

Benefits:

  • Someone loading your project can "just use" it, not further installation required

Caveats:

  • If someone uses your library (I don't know whether you build a library or a standalone project), and happens to add the same external JARs in different versions, this might lead to conflicts and confusion.
  • You need to check the licences of the external JARs to see what your obligations are if you extend their projects. You probably have to list the licenses and provide links to the original source code, at least.
J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • Thanks, I'm reading up on this now. Why would I want to use shading though, since the solution essentially seems to be to repackage the existing class files from the external jar into mine? The name spaces do not clash. – Arend Apr 11 '23 at 19:52
  • If you build your library with version 1.0 of `obscure-jar` and someone uses your library together with version 2.0 of `obscure-jar`, this may lead to strange behaviour at runtime. If you see no risk that someone tries to do this, then you need not rename/shade. – J Fabian Meier Apr 12 '23 at 08:28