Setup Maven and Nexus to manage Java package - lifuzu/cafe GitHub Wiki

Maven

  1. Download/Install Maven on Ubuntu

sudo apt-get install maven2
  1. Create an example Java package

mvn archetype:generate -DgroupId=com.mycom.app -DartifactId=my-app \
-DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
  1. Check the pom.xml under my-app folder

  2. Run Maven command to generate package


mvn clean install

Nexus

  1. Download/Install Nexus on Linux server here: http://www.sonatype.org/nexus/go

cd /usr/local
sudo tar zxvf nexus-2.5.1-01-bundle.tar.gz
sudo ln -s nexus-2.5.1-01 nexus

(untar will create two folders: nexus-2.5.1-01 and sonatype-work)

  1. Copy/Modify the Nexus startup script

sudo cp /usr/local/nexus/bin/nexus /etc/init.d/nexus

(change: NEXUS_HOME="/usr/local/nexus", RUN_AS_USER=<WHOAMI>, and PIDDIR="/tmp" )
(change the default port at: /usr/local/nexus/conf/nexus.properties, as application-port=8081)

  1. Update to default of Ubuntu startup level

sudo update-rc.d nexus defaults
  1. Change owner property for the folder /usr/local/sonatype-work

sudo chown USER:GROUP sonatype-work/ -R
  1. Try to run it and check it healthy

service nexus start

(check the log: /usr/local/sonatype-work/nexus/logs/nexus.log, and ps aux | grep nexus, or netstat -napt | grep 8081)

  1. Login to
    http://<HOST>:<PORT>
    to change Admin password, config SMTP etc., as: http://books.sonatype.com/nexus-book/reference/install-sect-repoman-post-install.html

Maven and Nexus

  1. Touch setting.xml on Maven image (call it client A), with the configuration of Nexus server

touch ~/.m2/settings.xml

https://gist.github.com/lifuzu/6034635

  1. Update the pom.xml under my-app https://gist.github.com/lifuzu/6034665

  2. Then run the deployment command under the my-app folder


mvn deploy
  1. That is it!
⚠️ **GitHub.com Fallback** ⚠️