tags:

views:

18

answers:

2

Hi Experts,

I am writing a pom.xml for my project to build a jar file.

Now for my source to compile i need to set-up some dependencies which are my common libraries for my entire project at about 100 jar files.

All these common lib's i have in a single directory (CommonLib).

So is there any way where i can set dependencies all for these common lib's just by referring the directory name of common lib's rather than defining dependencies for each individual jar file.

Regards Gnash-85

A: 

No, that's not possible. In Maven, you can use only dependencies from repositories - be it Maven Central, or one you host yourself.

You have two options:

  1. Set your own Nexus up and upload all dependencies to it. (That's easier than it sounds, but you'll need to run the server somewhere)
  2. Use mvn install to install the JAR files to your local Repository - but every developer will have to do this on every workstation he uses. You could create a script for that though.

Personally, I don't like to rely on external resources like Maven Central, so I usually move all dependencies to my own repository. As far as I know, Maven3 will allow to fetch dependencies not only from repositories but also from SSH/HTTP/FTP etc., I'm looking forward to that.

fhd
Well, you can already download from a repository using `file://` and **`http://`** (and many FTP sites are browsable with HTTP) with Maven 2.x (central is just a file system served by a web server).
Pascal Thivent
A: 

So is there any way where i can set dependencies all for these common lib's just by referring the directory name of common lib's rather than defining dependencies for each individual jar file.

While it IS possible to use a file-based repository, you'd still have to declare each dependencies in your pom individually.

As an alternative, you could generate MD5 checksums for your libs, search the corresponding artifact by checksum and generate the corresponding <dependency> element. The question below describes this approach (and an automated solution):

Pascal Thivent