News and Notes from the Makers of Nexus | Sonatype Blog

How to Use Nexus Repository With Maven Deploy [VIDEO]

Written by Awkash Agrawal | May 11, 2020
Most of the time it is fairly difficult for a junior developer to make sense out of things happening behind the scenes. This happened in one of my interactions with a junior developer recently. I asked, "what happens when you do a Maven deploy and Maven install?". I did not get the expected answer. Therefore, I felt that showing a practical example would help that person understand the set of activities happening behind the scenes, and could help you, too.
I divided this tutorial into series of easy-to-follow steps, below. I also recorded a video that demonstrates each step. If you are brand new to the topic, check out the free class that Sonatype offers called, " Repository Management Basics".
 
 
Step 1 - Create a snapshot repository for publishing the artifact on Nexus Repository OSS or Nexus Repository Pro. (To learn more about snapshot repositories and release repositories, refer to this discussion on Stack Overflow . )
 
Step 2 - Create a release repository used to publish the artifact to production.

Step 3 - Create a group repo, which is a combination of snapshot and release repo put together.

Step 4 - Download the initializer project from spring.io to create a sample project that will be published to repository.
 
Step 5 - Configure settings in xml file related to Maven. To learn more about settings please refer to this post by mykong

Step 6 - Create profiles in Maven, a concept used to group certain configuration under one heading. Here are some additional resources:
Step 7 -  Configure the credentials of your Nexus server.
 
Step 8 - Configure release and snapshot repo created in step 1 and 2 on the Maven side. This will allow Maven to publish the artifact to the repo.

Step 9 - Double check that the repo id matches. 

Step 10 - Run the command for publishing an artifact to Nexus Repository.

Steps 11 and 12 - Publish the artifact to release repo using a different profile in Maven.