If you are using Maven for build management you will very soon need to run a repository to store your artifacts and proxy remote artifacts so that your build is not blocked by external dependencies. Setting up a Nexus repository is as easy as deploying a war file to a web server. This tutorial covers the procedure for deploying the Nexus repository on a Jetty 6 web server.

Download Nexus war file

Nexus is distributed as a war file which can be downloaded at http://nexus.sonatype.org/downloads/. I used version 1.9.2 which can be downloaded from Here. Rename the downloaded file to something simpler such as nexus.war.

Download and Setup Jetty

Now download Jetty six from here http://dist.codehaus.org/jetty/. I used version 6.1.26 which can be downloaded from Here. Unzip jetty into a folder of your choice and browse to the "contexts" directory. Create a file here called nexus with the text shown below. The contextPath element specifies the context by which users will find the application on your server, e.g. http://[domain-name]/nexus/. The war element specifies the location of the WAR file inside the Jetty home directory, under the standard webapps folder, using a WAR file called nexus.war.

<?xml version="1.0"  encoding="ISO-8859-1"?>

<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">

<configure class="org.mortbay.jetty.webapp.WebAppContext">

    <set name="contextPath">
    	/nexus
    </set>
    <set name="war">
    	<systemproperty name="jetty.home" default="."/>/webapps/nexus.war
    </set>

</configure>

 

Now copy the Sonatype nexus war file into the webapps directory in the jetty base directory.

Running Jetty

Open a terminal instance at the jetty root directory and run the following command to start jetty.

java -jar start.jar

This should start your Nexus repository in the Jetty container. Fire up your favourite browser and go to http://[domain]:8080/nexus/ or http://localhost:8080/nexus/ if you are running Nexus on your local machine. You should be presented with the nexus front end and can start managing your repositories.

Note: The default admin user and password are "admin" and "admin123" respectively.

Further Reading

Please see the Nexus docs for details on how to create and manage maven repositories.