Setup Maven and Nexus to manage Java package - lifuzu/cafe GitHub Wiki
- Download/Install Maven on Ubuntu
sudo apt-get install maven2
- Create an example Java package
mvn archetype:generate -DgroupId=com.mycom.app -DartifactId=my-app \
-DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
-
Check the pom.xml under my-app folder
-
Run Maven command to generate package
mvn clean install
- 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)
- 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)
- Update to default of Ubuntu startup level
sudo update-rc.d nexus defaults
- Change owner property for the folder /usr/local/sonatype-work
sudo chown USER:GROUP sonatype-work/ -R
- 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)
- 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
- 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
-
Update the pom.xml under my-app https://gist.github.com/lifuzu/6034665
-
Then run the deployment command under the my-app folder
mvn deploy
- That is it!