When using Maven with open-source dependencies, most of the time they’re easily found in the standard Maven repository. Some of them though, due to licensing constraints, slow updates or any other reason, are missing and need to be hunted down and installed into your local repository.
Some projects have small repositories of their own, which are usually listed in their documents. There are however some public repositories which, similarly to the main one, store a multitude of libraries.
Here’s a list of the ones I use:
- Java.net Repository for Maven – stores a lot of Sun libraries
- JBoss Repository – home of JBoss builds, Hibernate and others
- Codehaus Repository – plenty of open-source projects, including many Maven plugins
- Codehaus Snapshots Repository – snapshot builds of some Codehaus projects
You could add their addresses to the POM files of any new project you’re starting. You probably should do that for the sake of easier build environment setup, when someone tries to checkout and build your code from scratch.
It’s useful also to add it to the settings.xml file in your .m2 directory. This would be located in either:
/home/<username>/.m2/directory on Linux, orC:\Documents and Settings\<username>\.m2\on Windows.
If there’s no settings.xml file inside there, create a new one and put the following in it (see Maven’s documentation for more information on how to structure the file):
<settings ...> <profiles> <profile> <id>general</id> <repositories> <repository> <id>maven2-repository.dev.java.net</id> <name>Java.net Repository for Maven</name> <url>http://download.java.net/maven/2/</url> <layout>default</layout> </repository> [... all other repositories] </repositories> </profile> </profiles><activeProfiles> <activeProfile>general</activeProfile> </activeProfiles> </settings>
After that every Maven’s dependency lookup will check these repositories as well.