Auxiliary Tools :: Nexus Repository Manager

 

Installation

I installed Nexus on pc-5-git-repo; IP=192.168.195.105

  1. Update server:
    yum update
  2. Install wget:
    yum install wget
  3. Create directory zibi:
    mkdir /zibi
    cd /zibi
  4. Download the Nexus:
    wget https://sonatype-download.global.ssl.fastly.net/nexus/3/nexus-3.0.2-02-unix.tar.gz
  5. Untar the downloaded file:
    tar -xvf nexus-3.0.2-02-unix.tar.gz
  6. Rename the untared file to nexus:
    mv nexus-3.0.2-02 nexus
  7. Create a new user named nexus:
    adduser nexus
  8. Change the ownership of nexus file to nexus user:
    chown -R nexus:nexus /zibi/nexus
  9. Open /zibi/nexus/bin/nexus.rc file, uncomment run_as_user parameter and set it as following:
    run_as_user=”nexus”
  10. Running Nexus As Service:
    ln -s /zibi/nexus/bin/nexus /etc/init.d/nexus
    chkconfig –add nexus
    chkconfig nexus on
    service nexus start (it takes a while)

Visit http://192.168.195.105:8081

To log in, use the default username and password:
user: admin
password: admin123

 

 

Configuring Nexus as a Maven Repository

We will need:

  • a private (hosted) repository for our snapshots
  • a private (hosted) repository for our releases
  • a proxy repository pointing to Maven Central
  • a group repository to provide all of these repos under a single URL

Snapshots Repository

A repository for Maven artifacts with

<version>1.0.0-SNAPSHOT</version>

in pom.xml.

Create a new maven (hosted) repository:
Releases Repository

A repository for Maven artifact that you deploy without -SNAPSHOT

<version>1.0.0</version>

in pom.xml.

Create a new maven (hosted) repository:
Proxy to Maven Central Repository

A repository that proxies everything you download from Maven Central.

Create a new maven (hosted) repository:
Group Repository

This will group all the above repos and provide you a single URL to configure your clients to download from/deploy to.

Create a new maven (hosted) repository:

Configuring Maven Projects to Use Nexus Repositories

Put this in your ~/.m2/settings.xml file. This will configure the credentials to publish to your hosted repos, and will tell your mvn to use your repo as a mirror of central:

And now configure your projects.
If you want only to download dependencies from Nexus, put this in the pom.xml:

And if you want also to publish your project, add:

Now if you run in your projects:

mvn install
or
mvn deploy

your mvn will point to your Nexus instance.

 

Leave a Reply