Related softwares:
- Eclipse 3.5
- JDK 1.6
- Maven 2.2.1
First, install M2clipse-plugin in Eclipse via below M2clipse update site:
http://m2eclipse.sonatype.org/update/
If you don’t know how, please refer to this article on how to install Eclipse plugin via update site.
To use the latest Maven2, which is version 2.2.1 at the point of writing this article, you need to download the binaries from below site:
http://lawyersdb.com/mirrors/apache/maven/binaries/apache-maven-2.2.1-bin.tar.gz
Once downloaded the apache-maven-2.2.1.tar.gz archive file, unzip/untar it and place the apache-maven-2.2.1 folder in /opt. So, /opt/apache-maven-2.2.1 will be known as $M2_HOME. To set this environment variable manuallly into the system, add this below line in /etc/environment file.
JAVA_HOME=/usr/lib/jvm/java-6-sun M2_HOME=/opt/apache-maven-2.2.1
Add also the $JAVA_HOME variable, if you haven’t done so. But make sure it is pointing to your JDK home folder. You need to re-login into your Ubuntu for this new environment variable to take effect
After re-login, create a mvn link in /usr/bin, for you to run the mvn command globally. Type the following:
cd /usr/bin ln $M2_HOME/bin/mvn /usr/bin/mvn
To check Maven2 installation status, type below command in your console:
mvn -version
You should see Maven2 printing some info regarding the version.
Back to the Eclipse. Now, you need to setup External Tools to point to this new /usr/bin/mvn command we just created. At Eclipse main menu, choose Run > External Tools > External Tools Configuration…

External Tools Configuration dialog will be prompted as below.

Right-click on Program and choose New.

A new program form will be displayed. Enter the following details:
- Name : Maven
- Location : /usr/bin/mvn
- Working Directory : ${project_loc}
- Arguments : ${string_prompt}

Click on Apply and Close buttons.
To use the newly created External Tools we just created, click to highlight your Maven2 project.

On the Eclipse main menu, choose Run > External Tools > External Tools Configuration…

Then, on the External Tools Configuration dialog, choose Maven and click on Run button.

A Variable input dialog will be prompted. Key in your mvn parameter you wish to pass and click OK button.

You will see your Maven2 console is running and processing your command as shown in below.

If you had setup a private remote repository, you can save the hassle for downloading artifacts from the public remote repository (central repo). Your private remote repository will download it for you and cache it on the private server. If you want to download from your private remote repository, you need to update or create your Maven2 settings.xml file. This file should be located at ${USER_HOME}/.m2 folder. The content of the file is as following:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups/>
<proxies/>
<servers/>
<mirrors>
<mirror>
<id>myPrivateRemoteRepository</id>
<mirrorOf>*</mirrorOf>
<name>My Private Remote Repository</name>
<url>[PRIVATE_REMOTE_REPOSITORY_URL]</url>
</mirror>
</mirrors>
<profiles/>
</settings>
Replace the [PRIVATE_REMOTE_REPOSITORY_URL] with your private remote repository URL. You can put any value on the id and name elements, but it just need to be unique between other mirrors.









