Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binary library dependencies in Maven / Eclipse

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?

like image 774
mikera Avatar asked Oct 11 '22 16:10

mikera


1 Answers

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>
like image 148
Will Avatar answered Oct 20 '22 16:10

Will