Jul 13, 2014

Maven with Nexus for distribution management

Q. What is Nexus?
A. Nexus is a central repository manager that stores and organizes binary software components for use in development, deployment, and provisioning. Nexus becomes the deployment destination for the components that are created by your organization using Maven.

  • You can publish your own library or project JARs, WARs, EARs etc. both sanapshot and release versions using Nexus Pro. 
  • You can host your own repository to support your custom components and share those components with other users or computers on your network. 
  • Once your components are placed in the repository - they can be made available to all developers securely using access controls and SSL.
  • You can search for artifacts.

Q. How to configure maven to publish artifacts to Nexus?
A. To configure a Maven project to publish artifacts to Nexus, you'll need to add a distributionManagement element to your project's pom.xml.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""


            <name>mycompany Snapshots</name>
            <name>mycompany Releases</name>


The child projects or modules will refer to the parent project


If your Nexus server requires authentication, you will also need to place your credentials in ~/.m2/settings.xml in a servers element.


Once you've configured your project's pom.xml and your Maven Settings, you can deploy your project with

mvn deploy

which will execute the build up to the deploy phase. When you run a deploy with a project that has a snapshot version, Maven will deploy to the repository defined in snapshotRepository, and when you run a build with a project that has a release version it will deploy to the repository defined in the repository element.

Q. What is the difference between snapshot versions and release versions?
A. The "SNAPSHOT" term means that the build is a snapshot of your code at a given time, which means downloading 1.0-SNAPSHOT  today might give a different file than downloading it yesterday or tomorrow. When you are ready to release your project, you will change 1.0-SNAPSHOT to 1.0 in the pom.xml file. The 1.0 is the release version. After release, any new developmwent work will stat using  1.1-SNAPSHOT and so on.



Post a Comment

Subscribe to Post Comments [Atom]

<< Home