Reputation: 106351
I'm new to Maven and trying to work out how to deal with a situation where I have a set of binary libraries (.jars) that I want to include in multiple Maven-managed projects.
The libraries don't have a pom.xml file and aren't available in any Maven repository.
How should I set up Maven / m2eclipse to include these libraries in my other projects? I'm assuming I need to set up some kine of Maven "wrapper project" to deal with these?
Upvotes: 5
Views: 2503
Reputation: 6286
If you're team programming use @limc post.
If it's just for you, there are a couple of ways of dealing with it:
There's a maven plugin to add the jar to your local repository.
mvn install:install-file -DgroupId=<your_group_name> \
-DartifactId=<your_artifact_name> \
-Dversion=<snapshot> \
-Dfile=<path_to_your_jar_file> \
-Dpackaging=jar \
-DgeneratePom=true
Or you can reference the jar file as a system dependency like so:
<dependency>
<groupId>com.package</groupId>
<artifactId>id</artifactId>
<version>5.2</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/my.jar</systemPath>
</dependency>
Upvotes: 3
Reputation: 40168
You will need to first install the jars into your Maven repo shown by @Will's post. Keep in mind, these jars only exist in your Maven repo. In another word, if you are sharing this project code with fellow developers, they have to do the same thing on their own local repos, or else they won't be able to find the jars.
A more elegant solution to team development like this is to host Nexus in some local server. What Nexus does is it groups all the external repositories into one spot (think of it as a proxy). So, you will want to install that jars in Nexus under "hosted repository" (there are 3 types of repo in Nexus, by the way). Then, configure all your team member's development to pull from Nexus instead of the internet. This way, when your team member checks out your project into their local workspaces, everything will be seamless and they will get the jars automatically too. You don't need to configure external repositories in your pom.xml this way. :)
Upvotes: 1