Introduction
Nexus is the best java artifact repository management software so far as I know. Enterprise software development shop should use repository management system to proxy the outside world repository and also to manage the life cycle of their internal software.This article will walk you through the fundamental process to install, start Nexus, and deploy an maven artifact to the Nexus repository. For the complete reference, you may take a look at this reference book. Personally, I don't like this kind of reference. Nowadays, who has the time to read through the whole books?
Download and Install Nexus OSS
- Go to this page to download the Nexus OSS
- Download nexus-2.11.0-02-bundle.tar.gz (this is the current version)
- cd ; mkdir nexus ; cd nexus
- tar xvzf ~/Downloads/nexus-2.11.0-02-bundle.tar.gz
[/Users/Gary2013/nexus/nexus-2.11.0-02]$ ls LICENSE.txt NOTICE.txt bin conf lib logs nexus tmpAt this point the installation is done. we can start the Nexua OSS by:
cd bin ./nexus start
Configure Nexus OSS
By default, Nexus use http port 8081. You can open a browser and go to http://localhost:8081/nexus Once the default Nexus page is rendered, you can login in using the default admin:username: admin password: admin123Nexus has preconfigured a deployment user with:
username: deployment password: deployment123First thing I did is to add a new uer [from left panel -> security] as shown in the following figure:
Configure Maven
In order to deploy java artifacts to Nexus Repository, we will need to update maven configuration file ~/.m2/setttings.xmlsdeployment deployment deployment123 gary gary gary1234
Project Configuration To Use Local Nexus
After Nexus starts, we need to configure our project to be deployable to the Nexus repository. Here is all we need to do in our pom.xml file
4.0.0 com.ggl.fuse fuse.message 0.0.2-SNAPSHOT deployment http://localhost:8081/nexus/content/repositories/releases deployment http://localhost:8081/nexus/content/repositories/snapshots org.sonatype.plugins nexus-staging-maven-plugin 1.6.3 default-deploy deploy deploy deployment http://localhost:8081/nexus/ true
If you look at the Nexus repository, you will find releases and snapshots as shown in the following figure:
The question is how does maven know into which repository the artifacts should be put? The answer is that in our version tag. If we put the version like:
0.0.2-SNAPSHOT
The maven will put the artifact into snapshots repository. If the version has no SNAPSHOT, the artifacts will be put into release repository
No comments:
Post a Comment