Centralized Maven Repository - Such As Nexus

Most enterprises will likely need some form of centralized maven repository of some form, to manage your compiled maven project artifacts.  One open source offering of such is from Sonatype, Nexus OSS.


A quick download and unzip installation will get you up and running quickly.

Unzip the downloaded binary to a directory of your choice.  

Once extracted, start the application which runs on top of a jetty server 
on Linux/OSX
<nexus_home>/bin/nexus start 

or you can specify "nexus console" instead of "nexus start" to see it running in your console window.

In your browser, navigate to the following URL:
http://localhost:8081/nexus/

default credentials are:
Username: admin
Password: admin123

Clicking "Repositories" you will find a series of repositories which are predefined, as well as a "Releases" & "Snapshots" which will likely be where your artifacts may be going.

Releases by default are set to a Deployment Policy to Display Redeploy to protect the integrity of your repository.  Snapshots on the other hand Allow Redeploy.  However, these are configurable.

Once your repository is up and running, you'll want to start editing some of your POM files to set them up to distribute your built artifacts to your nexus repository.

From Sonatype, Configure Maven to Deploy to Nexus

You'll likely also want to pull artifacts from your repository as well, so your maven settings.xml needs to be updated.

From Sonatype, Configure Maven to Download from Nexus

Based on the configuration defined above, if you have multiple repositories defined in your settings.xml you can change it so only the repositories with an id of central are used for the mirror.  Or you can remove the mirrors all together and put the URL in their respective sections, replacing http://central.  Since the nexus may be your central repository within your organization you may want to consider proxying or mirroring other third party maven repositories to increase local LAN speeds as opposed to connecting to remote repositories.

<mirrorOf>*</mirrorOf>
to
<mirrorOf>central</mirrorOf>

Once you have it all set up, a "mvn deploy" should push your artifacts to your configured nexus repository.


References:
http://www.sonatype.org



comments powered by Disqus