views:

2286

answers:

5

Hello,

in my J2EE project I've a couple of dependencies, which are not available in any Maven repository, because they're proprietary libraries. These libraries need to be available at runtime, so that have to be copied to target/.../WEB-INF/lib ...

Right now, I'm listing them as system dependency in my POM, but with this method the problem is, that aren't being copied to the target build during compilation. Also this method is not very elegant.

So which is the best way to integrate them in Maven?

Note: I don't want to create my own Maven repository.

+1  A: 

you can install them in a private, local repository (e.g. .m2/repository under your home directory): more details here

dfa
Yes I could do that, but then I'd have to tell everyone who wants to build the project that he has to put files X, Y in directory Z and that really complicates things. After all I want to use Maven to simplify the build process.
samson
+5  A: 

You need to set up a local repository that will host such libraries. There are a number of projects that do exactly that. For example Artifactory.

Gregory Mostizky
Also archiva: http://archiva.apache.org/
teabot
And Nexus: http://nexus.sonatype.org/
teabot
A point on terminology, those are internal remote repositories, not local repositories. The local repository is the one on the local file system dependencies are downloaded to.
Rich Seller
+1  A: 

If I am understanding well, if what you want to do is to export dependencies during the compilation phase so there will be no need to retrieve manually each needed libraries, you can use the mojo copy-dependencies.

Hope it can be useful in your case (examples)

ipingu
+3  A: 

As you've said you don't want to set up your own repository, perhaps this will help.

You can use the install-file goal of the maven-install-plugin to install a file to the local repository. If you create a script with a Maven invocation for each file and keep it alongside the jars, you (and anyone else with access) can easily install the jars (and associated pom files) to their local repository.

For example:

mvn install:install-file -Dfile=/usr/jars/foo.jar -DpomFile=/usr/jars/foo.pom
mvn install:install-file -Dfile=/usr/jars/bar.jar -DpomFile=/usr/jars/bar.pom

You can then reference the dependencies as normal in your project.

However your best bet is still to set up an internal remote repository and I'd recommend using Nexus myself. It can run on your development box if needed, and the overhead is minimal.

Rich Seller
Thanks this method is working good for me now. I extended the POM so that files are being automatically being installed to the local rep:http://pastebin.ca/1504318
samson
Glad to help, but as others have said the best approach would be to use a Maven repository manager. This approach does not scale well.
Rich Seller
+1  A: 

Continue to use them as a system dependency and copy them over to target/.../WEB-INF/lib ... using the Maven dependency plugin:

http://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-artifacts.html

Corehpf