Before covering a topic on Nexus repository manager, let's first understand the various types of repositories in Maven. In Apache Maven, there are 3 basic types of repositories :
- Local
- Central
- Remote
Let me quickly cover a few basics about each one of them :
The Local Repository is the local folder on your machine that you mention in the project's settings.xml with <localRepository> tags. This is where all the artifacts - plugin jars, dependencies and other configuration files that Maven downloads, would be stored.
The Central Repository is http://repo.maven.apache.org/maven2 which redirects you to http://search.maven.org/#browse. If the dependencies are not found in the local repository, Maven attempts to download them from this central repository. This is Maven's official central repository, where you search for various artifacts. This is analogous and similar to Perl's CPAN for searching modules.
Note that at the time of build, the download of dependency is triggered only if the required dependency is mentioned in pom.xml.
On certain occasions, it may happen that the required dependency does not exist on either local or central repository. It may exist on some other Remote Repository. For instance : Jboss or Java.net repository. In that case we have to mention the remote repository url in the pom.xml so that at the time of build, Maven will scan pom.xml and download the dependency jars from the mentioned remote url.
Remember, the thumb rule for Maven's dependency management is as follows :
- First it will search local repository for the dependency.
- If dependency is not found in local repository, it will download it from central repository.
- If dependency does not exist on either local or central repository, it will download it from the remote repository url mentioned.
Guys, more Maven posts are in the pipeline. Lots of useful information is coming up. Be positive, stay healthy and enjoy your life :)
No comments:
Post a Comment