Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add external jar to maven webapp project

Tags:

maven

I have a Spring roo project (basically a maven project). I want to add dropbox sdk to the project, problem is it's not in maven. I added the following files

    <dependency>
        <groupId>com.dropbox</groupId>
        <artifactId>dropbox-sdk</artifactId>
        <version>1.3.1</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/libs/dropbox-java-sdk-1.3.1.jar</systemPath>
    </dependency>

It solved the compile error, but when i run the project, in Spring Tool Suite, the jar files are not added to war lib folder. How do I make maven add my external jar files to my the war lib folder?

I don't want to install the jar in maven since, I have to install it in all the machines that uses the project

like image 567
Charlie Wu Avatar asked May 19 '12 12:05

Charlie Wu


1 Answers

I finally found a neat solution, which is a lot easier to implement. You add an in-project repository inside the java project and link to it in the pom.

You add an in-project repository in maven like this:

<repository>
    <id>in-project</id>
        <name>In Project Repo</name>
        <url>file://${project.basedir}/libs</url>
</repository>

Then create a folder structure in the root folder of your project that looks something like this

/groupId/artifactId/version/artifactId-version.jar

and add the dependency as you would normally do.

This approach has the least amount of code and work required, and if that library ever gets add into a maven repository you can always remove your in-project repository.

http://bit.ly/OGVHSN

like image 176
Charlie Wu Avatar answered Oct 14 '22 05:10

Charlie Wu