Iam writing a pom.xml in maven2 for buillding a jar can i include all dependencies?
I am writing a pom.xml for my开发者_StackOverflow 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
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:
- 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)
- 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.
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):
- Finding the right version of the right JAR in a maven repository
精彩评论