If you are using maven for builds or dependency management you will notice that by default maven always attempts to pull dependencies from the public maven repository (repo1).
After reading documentation and examples I thought you could easily override this by specifying a local repository in your respective project object model file (pom.xml). Example.
Not the case in my experience. Every attempt to specify a local repository always resulted in the official maven repo being checked first. If the dependency was not available in the public repo it would then check the local repo.
After some reading I found the useful maven command “help:effective-pom” which does what it says. It takes all the information being inherited from other poms and spits out the xml for what is your effective pom.xml file when maven is run. The maven repo is included in maven’s “super pom” which is inherited by all poms. No matter what I tried the repository entry from the super pom is always first in line before all over repos.
The only way I could override this was to use the“mirror” element in the settings.xml file which can reside in either /etc/maven2/ for system wide settings or ~/.m2/ for user settings. This is not ideal for us because we want everyone who checks out this maven project to automatically use our local repo without having to touch config files on their machine. For the linux machines its not a big deal because we can control this file with puppet but its a slight pain for everything else.
One Trackback
[...] In a previous post I mentioned using the settings.xml file to force maven to use a local repository. In my case this is Jfrog’s Artifactory. [...]