DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Getting started with Nexus Maven Repo Manager

Getting started with Nexus Maven Repo Manager

Vineet Manohar user avatar by
Vineet Manohar
·
Jun. 07, 10 · Java Zone · Interview
Like (3)
Save
Tweet
96.85K Views

Join the DZone community and get the full member experience.

Join For Free

This tutorial outlines steps required to install Nexus (Maven Repository Manager) under Tomcat, or another webapp container. It shows you practical configuration and includes code snippets that go in your pom.xml and settings.xml in order to read and publish artifacts to your Nexus server.

Step 1: Download

Download Nexus from here (at the time of writing, latest is 1.6.0)

Step 2: Install

Copy the war to TOMCAT_HOME/webapps/nexus.war

Though not required, it is a generally good idea to restart tomcat after installing a new war

  /etc/init.d/tomcat restart  
/etc/init.d/tomcat restart

Step 3: Configure security

a) Change default admin password: The default admin username/password is admin/admin123. Login as admin and change the password to a secure password.

Login -> [admin, admin123] -> Left Menu -> Security -> Change Password -> click “Change Password”

b) Anonymous Access: By default Nexus is open to the public. If you want to secure access to nexus, disable ‘Nexus anonymous user’

Admin -> Left Menu -> Users -> ‘Nexus anonymous user’ -> Status=Disabled

c) Deployment user: Change password for deployment user

Admin -> Left menu -> Users -> Deployment user -> Change email address

Admin -> Left menu -> Users -> Right click on ‘Deployment user’ in the user list -> Set Password -> click ‘Set password’ to finish

Step 4: Set SMTP server

It is a good idea to configure SMTP server, so that you can receive emails from Nexus.

Admin login -> Left menu -> Administration -> Server ->SMTP Settings -> (host localhost, port 25, no login, no password mostly works on a linux machine)

Step 5: Change Base Url

If you are running Nexus behind Apache using mod_jk or mod_proxy, change your base url here.

Admin login -> Left menu -> Administration -> Server -> Application Server Settings -> Base url

Step 6: Add a task to periodically remove old snapshots

If you or your CI server publishes snapshots to Nexus several times a day, then you should consider adding a task to delete duplicate/old snapshots for the same GAV (group, artifact, version). If you don’t do this, you will notice that the Nexus disk usage will increase with time.

Admin login -> Left menu -> Administration -> Scheduled tasks -> Add… -> name=”Remove old snapshots”, Repository/Group=Snapshots (Repo), Minimum Snapshot Count=1, Snapshot Retention(days)=3, Recurrence=Daily, Recurring time=2:00 -> click ‘Save’

Step 7: Using Nexus: reading and publishing artifacts

If you want to deploy your artifacts to your Nexus, you need to configure 2 files: pom.xml and settings.xml

a) pom.xml – for each project which wishes to publish to Nexus, add your repo to the pom.xml

<distributionManagement>
<!-- Publish the versioned releases here -->
<repository>
<id>vineetmanohar-nexus</id>
<name>vineetmanohar nexus</name>
<url>dav:http://nexus.vineetmanohar.com/nexus/content/repositories/releases</url>
</repository>

<!-- Publish the versioned releases here -->
<snapshotRepository>
<id>vineetmanohar-nexus</id>
<name>vineetmanohar nexus</name>
<url>dav:http://nexus.vineetmanohar.com/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<!-- download artifacts from this repo -->
<repositories>
<repository>
<id>vineetmanohar-nexus</id>
<name>vineetmanohar</name>
<url>http://nexus.vineetmanohar.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>

<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<!-- download plugins from this repo -->
<pluginRepositories>
<pluginRepository>
<id>vineetmanohar-nexus</id>
<name>vineetmanohar</name>
<url>http://nexus.vineetmanohar.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
 <!-- Publish the versioned releases here -->
 <repository>
  <id>vineetmanohar-nexus</id>
  <name>vineetmanohar nexus</name>
  <url>dav:http://nexus.vineetmanohar.com/nexus/content/repositories/releases</url>
 </repository>

 <!-- Publish the versioned releases here -->
 <snapshotRepository>
  <id>vineetmanohar-nexus</id>
  <name>vineetmanohar nexus</name>
  <url>dav:http://nexus.vineetmanohar.com/nexus/content/repositories/snapshots</url>
 </snapshotRepository>
</distributionManagement>

<!-- download artifacts from this repo -->
<repositories>
 <repository>
  <id>vineetmanohar-nexus</id>
  <name>vineetmanohar</name>
  <url>http://nexus.vineetmanohar.com/nexus/content/groups/public</url>
  <releases>
   <enabled>true</enabled>
  </releases>

  <snapshots>
   <enabled>true</enabled>
  </snapshots>
 </repository>
</repositories>

<!-- download plugins from this repo -->
<pluginRepositories>
 <pluginRepository>
  <id>vineetmanohar-nexus</id>
  <name>vineetmanohar</name>
  <url>http://nexus.vineetmanohar.com/nexus/content/groups/public</url>
  <releases>
   <enabled>true</enabled>
  </releases>
  <snapshots>
   <enabled>true</enabled>
  </snapshots>
 </pluginRepository>
</pluginRepositories>

b) settings.xml – If you have disabled anonymous access to Nexus, add the deployment password to your ~/.m2/repository/settings.xml file

<settings>
<servers>
<server>
<!-- this id should match the id of the repo server in pom.xml -->
<id>vineetmanohar-nexus</id>
<username>deployment</username>
<password>password_goes_here</password>
</server>
</servers>
</settings>

 

From http://www.vineetmanohar.com/2010/06/getting-started-with-nexus-maven-repo-manager

Nexus (standard)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How to Submit a Post to DZone
  • DZone's Article Submission Guidelines
  • Datafaker: An Alternative to Using Production Data
  • How to Determine if Microservices Architecture Is Right for Your Business

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo