How to add external libraries in Maven

While I was working on dropbox writer, I run into this problem. I have a maven based project that to use dropbox java SDK, but dropbox java SDK is not in any well known Maven repository. So I did some research on add dropbox sdk dependency to maven. After two days of trial and erros I’ve found a few ways to approach this.

First thing I found was to add system path property under dependency configuration, but this solution excludes the library from maven build.

Also I found people suggest that I should create my own maven repository. If you are interested this blogs have details on how to create maven repository in github. While this is a workable solution, I don’t really want to maintain a dedicated maven repository.

The best solution I found was to create an in project repository. The idea is your will create a library folder inside your project. You’ll configure your pom to point to the repository and it will act as a normal maven repository.

To get started first you need to create a library folder under your project, I’ll call this folder libs (make sure it’s in the same folder as your pom). Then you create a sub folder structure under libs and name your library using the following convention.


I’ve created the following structure for dropbox sdk library

groupId = dropbox
artifactId = dropbox-sdk
version = 1.3.1
the library file = dropbox-sdk-1.3.1.jar

Next open your pom.xml and add the following block under repositories

<!-- In Project repository -->
	<name>In Project Repo</name>

This will point to you in project repository. The name field can be anything.

Now in the pom.xml you can add dropbox dependency as following


Notice the groupId, artificatId and verion follows the pattern described above.

You can add multiple dependencies by creating them in separate folder structure under libs.

  1. Allen Hadden

    This was very helpful. Thanks! Note that instead of constructing the libs directory structure manually, you can also do this:

    mvn install:install-file -Dfile=dropbox-sdk-1.3.1.jar -DgroupId=dropbox -DartifactId=dropbox-sdk -Dversion=1.3.1 -Dpackaging=jar -DlocalRepositoryPath=lib -DcreateChecksum=true

    This will create the structure for you and also create the checksum metadata to avoid the Maven warning.

  2. Thanks for the information. You have safe my time.

  3. Hi,

    great article. You might want to add a more common case when you have domain name like

    Also you can try to use
    mvn deploy:deploy-file -Durl=file:///path/to/yourproject/repo/ -Dfile=mylib-1.0.jar -DgroupId=com.example -DartifactId=mylib -Dpackaging=jar -Dversion=1.0

    to autoamtically deploy the depedency.

Leave a Comment