Loading




Installing Maven 3 from a Binary DEB on Ubuntu

21 Apr 2011
Posted by tobrien

I'm on an automation kick lately. I've had to install Maven on an Ubuntu machine hundreds (if not thousands) of times and I finally decided that it was time to create a custom binary package to solve this problem. I did this because Maven 3 isn't available on Ubuntu, and I'm not going to wait for Debian packaging to repackage everything.

My usual process for installing Maven is:

  1. Download the archive from the ASF.
  2. Unpack the archive somewhere.
  3. Copy the expanded Maven archive to /usr/local.
  4. Create a symbolic link /usr/local/maven -> /usr/local/apache-maven-1.1.1
  5. Create a file in /etc/profile.d/maven.sh which will set the M2_HOME and PATH variables accordingly.
  6. Run Maven, and troubleshoot...

Since this seems like a lot of manual busywork, here's a custom DEB package. To install it, just execute the following commands on Ubuntu 10.04 (or 10.10):

sudo apt-get install python-software-properties
sudo add-apt-repository "deb http://build.discursive.com/apt/ lucid main"
sudo apt-get update
sudo apt-get install maven

This package depends on the java6-sdk, and by default it will install the OpenJDK 6 JDK. If you want to use the Sun JDK, you will need to add the "http://archive.canonical.com/ lucid partner" repository. Once the package is installed, log out and log in again. This package just drops Maven into /usr/local/, creates a symbolic link, and then creates a file in /etc/profile.d/maven.sh that sets M2_HOME and PATH.

Here's a video walk-through: