Thursday, June 30, 2011

Sharing Maven local repository with DropBox

Maven stores copies of libraries your projects depend on in to a local directory called local repository. Making this repository available to all the developers in your team can be beneficial, especially if you have multiple manually added libraries (for example Andengine doesn’t have a Maven repository so the libraries need to be manually added to your local repository.
Easy and free way of sharing this local repo is:
  1. All developers register and install Dropbox.
  2. You create a localRepository directory under your Dropbox folder.
  3. You share the localRepository folder to rest of your developers.
  4. All developers configure their Maven to use the Dropbox folder as their localRepository.
Location of your local Maven repository can be configured in settings.xml, either in the <user_home>/.m2 directory, or in the <maven installation>/conf directory. You need to add a new <localrepository> tag. For example:
<localrepository>C:/Users/someone/Documents/My Dropbox/localRepository</localrepository>

That’s it! Thanks Eric Lefevre-Ardant for the tip on changing the repo location.


  1. What does the Pom.xml file look like after you change the settings.xml file? In other words, how would the project now where to find these external jars if there is no location repo set up?

  2. Maven checks the settings.xml and finds the location of the local repo from there. POM doesn't require any changes. As your dropbox can be in a different path than your co-workers, it would not be a good idea to include the repo location in the shared pom.xml.

  3. @Janne

    Thanks for your reply, after changing the settings.xml file to now include the local repository location, will this affect current projects already accessing my local repository? If i have already added external jars to my local repo, do i need to move everything to this new location?

  4. When you change the settings.xml to point to a new location, maven will have no idea about the previous repository. If you have manually added files to your local repo, you can copy the repo to the new location. If not, you can also just delete the previous repo, run your maven builds as usual and maven will download everything to the new local repository.

  5. I hate to come back to this post but i am having some trouble seeing the changes i made to my settings.xml file. After creating a tag in that file and providing the absolute path to my already created 'localRepository' directory in dropBox, what do i need to run to see files in that directory (aka see changes happen)?