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:
- All developers register and install Dropbox.
- You create a localRepository directory under your Dropbox folder.
- You share the localRepository folder to rest of your developers.
- 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:
<settings>
...
<localrepository>C:/Users/someone/Documents/My Dropbox/localRepository</localrepository>
...
</settings>
That’s it! Thanks Eric Lefevre-Ardant for the tip on changing the repo location.
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?
ReplyDeleteMaven 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.
ReplyDelete@Janne
ReplyDeleteThanks 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?
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.
ReplyDeleteI 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)?
ReplyDelete