Acuariano
Acuariano

Reputation: 498

Creating dependencies from directory

Does anyone know a tool to create the Maven dependencies from a lib directory? I have several web projects with quite a lot of JARs and would like to "mavenize" them. Looking for the proper dependency for each one is quite a pain and seems like something that may be solved with a program.

Upvotes: 1

Views: 77

Answers (3)

opticyclic
opticyclic

Reputation: 8106

Ant2Ivy https://github.com/myspotontheweb/ant2ivy is a Groovy script that can do this.

Despite its name, it can also create pom files (https://github.com/myspotontheweb/ant2ivy/commit/9e3e8358f2b31507b13f5def69627da422e1656b).

It looks up the names/hash in Maven Central for you in order to create the pom.

Upvotes: 1

carlspring
carlspring

Reputation: 32597

You can write a plugin which adds all the dependencies (with <scope>system</scope> to the project's dependencies list. You can check how to do this by having a look at the build-helper-maven-plugin.

I would strongly object doing this. Look, if you're going to use Maven to do your Ant monkey-business, just use Ant for that. Will save you time and effort.

If on the other hand you would like to "Mavenize your build", you should really Mavenize it properly and not be lazy about it. Solutions are only as crappy as you make them. If you're lazy, they'll be a mess either way, so the effort would be pointless.

I suggest you add each of the dependencies using either of:

And do the job right. In addition, install an artifact repository manager as well. :) Good luck.

Upvotes: 0

Georgemc
Georgemc

Reputation: 369

Well, since these jars (presumably) didn't come from Maven in the first place, they won't contain a manifest that tells your their GAV co-ords. So it's hard to see how a tool could infer what's needed from just a directory. Unless you're phenomenally lucky and every jar has the exact arteface ID and version in the filename, in which case you might be able to script something.

You probably don't want that anyway. A lot of those jars, I'm betting, are transitive dependencies, and you don't really want them littering your POM.

tl;dr bite the bullet and just Mavenise it by hand. You could always write a script that uses a bit of wget magic against the public repos or something, to help you along the way.

Upvotes: 2

Related Questions