Andrej Koelewijn

  • Home
  • About
  • Publications
  • Departments
    • agile
    • architecture
    • cloud
    • java
    • mobile
    • open standards
    • oracle
    • oss
    • other
    • soa
    • software development
    • tablet
    • Uncategorized
    • web
  • Subscribe via RSS

Getting started with Nexus maven repository manager

March 9th, 2010  |  Published in java, oss, software development  |  3 Comments

Nexus is a maven repository manager. You can use Nexus to host your own maven repository for artifact created in your company, or for caching external artifacts.

Getting started with Nexus is pretty easy. Download the application. The package contains a webserver, so you don’t have to have a java container running. Simply unpack the downloaded archive and start the applications:

cd nexus/nexus-webapp-1.5.0/bin/jsw/linux-x86-32/
nexus start

Nexus has a web interface for managing your maven repository. The url for this web app is: http://localhost:8081/nexus/. The preconfigured admin account is admin, password: admin123.

According to the Nexus documentation you need to enable remote index downloads on a new installation, but it seems that this has been removed in the latest Nexus release. I couldn’t find the checkbox mentioned in Nexus 1.5.0.

Next you need to tell maven to use your maven repository. To do this, modify $HOME/.m2/settings.xml as follows:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <proxies></proxies>
  <servers></servers>
  <pluginGroups></pluginGroups>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

To make sure you are actually using dependencies downloaded through nexus, delete all dependencies maven has already cached on your system:

rm -rf ~/.m2/repository

To test this Nexus setup, we can create a little java application using maven. The following create a java web application:

mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=nl.iteye -DartifactId=App1
cd App1

You should now be able to compile and package your application:

mvn clean install

Next we’ll add the embedded glassfish maven plugin to our pom so we can test the web application. Add the plugin in the build section of your pom:

    <plugins>
         <plugin>
            <groupId>org.glassfish</groupId>
            <artifactId>maven-embedded-glassfish-plugin</artifactId>
            <version>3.0</version>
            <configuration>
               <app>${project.build.directory}/${build.finalName}.war</app>
               <port>7070</port>
               <containerType>web</containerType>
            </configuration>
         </plugin>
    </plugins>

When you try to run your application using the embedded glassfish plugin you’ll run into an error as maven will not be able to download all the required dependencies:

$:~/projects/jee/App1$ mvn embedded-glassfish:run
[INFO] Scanning for projects...
Downloading: http://localhost:8081/nexus/content/groups/public/org/glassfish/maven-embedded-glassfish-plugin/3.0/maven-embedded-glassfish-plugin-3.0.pom
[INFO] Unable to find resource 'org.glassfish:maven-embedded-glassfish-plugin:pom:3.0' in repository central (http://central)
Downloading: http://localhost:8081/nexus/content/groups/public/org/glassfish/maven-embedded-glassfish-plugin/3.0/maven-embedded-glassfish-plugin-3.0.pom
[INFO] Unable to find resource 'org.glassfish:maven-embedded-glassfish-plugin:pom:3.0' in repository central (http://central)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).

Project ID: org.glassfish:maven-embedded-glassfish-plugin

Reason: POM 'org.glassfish:maven-embedded-glassfish-plugin' not found in repository: Unable to download the artifact from any repository

  org.glassfish:maven-embedded-glassfish-plugin:pom:3.0

from the specified remote repositories:
  nexus (http://localhost:8081/nexus/content/groups/public)

 for project org.glassfish:maven-embedded-glassfish-plugin

To fix this problem we need to add the maven repository containing the glassfish plugin to Nexus. Log into Nexus using the admin account and, select repositories,and then add a proxy repository. Specify the following repository:

Next we need to add the glassfish proxy repository to the Public Repositories group:

Move the Glassfish Maven 2 Repository from available repositories to ordered group repositories:

Now you should be able to start Glassfish using maven, as Nexus will be able to find the required dependencies:

$:~/projects/jee/App1$ mvn embedded-glassfish:run
[INFO] Scanning for projects...
Downloading: http://localhost:8081/nexus/content/groups/public/org/glassfish/maven-embedded-glassfish-plugin/3.0/maven-embedded-glassfish-plugin-3.0.pom
4K downloaded  (maven-embedded-glassfish-plugin-3.0.pom)
[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = '7e111e395ec93ac48034fdf599552d547dc27618'; remote = '085185fbf2f1b3d0d36e557f4d42c9f47edc4d2c' - RETRYING
Downloading: http://localhost:8081/nexus/content/groups/public/org/glassfish/maven-embedded-glassfish-plugin/3.0/maven-embedded-glassfish-plugin-3.0.pom
4K downloaded  (maven-embedded-glassfish-plugin-3.0.pom)
[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = '7e111e395ec93ac48034fdf599552d547dc27618'; remote = '085185fbf2f1b3d0d36e557f4d42c9f47edc4d2c' - IGNORING
Downloading: http://localhost:8081/nexus/content/groups/public/org/glassfish/maven-embedded-glassfish-plugin/3.0/maven-embedded-glassfish-plugin-3.0.jar
16K downloaded  (maven-embedded-glassfish-plugin-3.0.jar)
[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = 'd6e53dbbc063ccb40aa673f0a56bafa0c2c225db'; remote = '0469be7e503a1c3df4c8ddf199b1fba3a998cca2' - RETRYING
Downloading: http://localhost:8081/nexus/content/groups/public/org/glassfish/maven-embedded-glassfish-plugin/3.0/maven-embedded-glassfish-plugin-3.0.jar
16K downloaded  (maven-embedded-glassfish-plugin-3.0.jar)
[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = 'd6e53dbbc063ccb40aa673f0a56bafa0c2c225db'; remote = '0469be7e503a1c3df4c8ddf199b1fba3a998cca2' - IGNORING
[INFO] ------------------------------------------------------------------------
[INFO] Building App1 Maven Webapp
[INFO]    task-segment: [embedded-glassfish:run]
[INFO] ------------------------------------------------------------------------
Downloading: http://localhost:8081/nexus/content/groups/public/org/glassfish/extras/glassfish-embedded-all/3.0/glassfish-embedded-all-3.0.pom
10K downloaded  (glassfish-embedded-all-3.0.pom)
Downloading: http://localhost:8081/nexus/content/groups/public/org/glassfish/extras/extras/3.0/extras-3.0.pom
2K downloaded  (extras-3.0.pom)
Downloading: http://localhost:8081/nexus/content/groups/public/org/glassfish/glassfish-parent/3.0/glassfish-parent-3.0.pom
53K downloaded  (glassfish-parent-3.0.pom)
...
INFO: Security service(s) started successfully....
classLoader = WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)
SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@181c4eb
Mar 9, 2010 9:34:51 PM com.sun.enterprise.web.WebApplication start
INFO: Loading application App1 at /App1
Hit ENTER to redeploy, X to exit

That’s about it.

  • Pingback: ทำความรู้จัก nexus โดย sonatype | kajookdev

  • xanadu

    To complete your article find at http://www.java-tutorial.ch/maven/maven-release how to release in a nexus repository

  • Pingback: Create custom maven repository to store artifacts unavailable in general maven repositories | Out Of Singularity

Tags

activemq agile bi camel css esb google governance grails groovy gtalk html5 internet ipad ivy J2EE java javascript jaxrs jmx jquery lean linkeddata linux maven mule noiv openoffice opensource Open Source oracle osgi oss rdbms rest scrum servicemix soa sql svg tablet web 2.0 XML xmpp yql

Archives

  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • June 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007
  • February 2007
  • January 2007
  • December 2006
  • November 2006
  • October 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006
  • April 2006
  • March 2006
  • January 2006
  • December 2005
  • November 2005
  • October 2005
  • September 2005
  • August 2005
  • July 2005
  • June 2005

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Recent Posts

  • Updating a vagrant box
  • Using littleproxy in Mule unit tests
  • Useful site to determine what html5, css3 & svg you can use
  • A Product Owner is a Project Manager
  • Using css webfonts in inkscape

Categories

  • agile
  • architecture
  • cloud
  • java
  • mobile
  • open standards
  • oracle
  • oss
  • other
  • soa
  • software development
  • tablet
  • Uncategorized
  • web

Recent Comments

  • Pcdiggs on Software architecture, PHP and Javascript
  • Een Scrum Product Owner is een Project Leider on A Product Owner is a Project Manager
  • Using css webfonts in inkscape :: Andrej Koelewijn on Create presentations using inkscape
  • Create presentations using inkscape :: Andrej Koelewijn on Presentation: Introduction to Scrum
  • Gebhard Greiter on What is Agile?
Buzz
andrkoel: Utrecht hele dag mist, scheveningen zomerse dag... http://t.co/cDRCJHr9
4:35 PM Nov 10, 2011, comment
andrkoel: RT @stefanvdkamp: Beter filmpje van Garret McNamara in de 30 meter hoge golf. http://t.co/9abiWkYX
9:20 AM Nov 10, 2011, comment
andrkoel: Mmm, een uur voor den haag - leiden lijkt te weinig, ga mijn afspraak niet redden...
7:34 AM Nov 10, 2011, comment
andrkoel: Big Data is Useless without Science http://t.co/2I8EiLsH
6:18 AM Nov 10, 2011, comment
andrkoel: Just tried #vagrant to quickly setup virtualbox development environment. Looks good, although provisioning apache through puppet failed...
10:47 PM Nov 09, 2011, comment
 


©2012 Andrej Koelewijn
Powered by WordPress using the Gridline Lite theme by Graph Paper Press.