Tuesday Sep 03

Maven installation and configuration for Ubuntu

PDF Print E-mail
Tuesday, 29 March 2011 14:17
AddThis Social Bookmark Button


Maven Installation for Ubuntu Maven installation guide for ubuntu

Maven installation and configuration for Ubuntu

This document describes how to install Maven on Ubuntu

Requirement

Java JDK 1.5 or above (this is to execute Maven - it still allows you to build against 1.3 and prior JDK's)
Memory o minimum requirement

Installation

Installation of Maven on ubuntu can be pretty straightforward

$ sudo apt-get install maven2

Files should be installed in /usr/share/maven2
Maven installation instructions for Ubuntu

Verification

Type “mvn -version ” to verify the installation.

 
$ mvn -version 
 Maven version: 2.0.9 
 Java version: 1.6.0_0  
 OS name: "linux" 
 version: "2.6.28-11-generic" 
 arch: "i386"
 Family: "unix" 

Where the Maven installed?

The Apt-get installation will install all the required files in the following folder structure

/usr/bin/mvn 
/usr/share/maven2/
/etc/maven2 

P.S The Maven configuration is store in /etc/maven2

Configuring Maven to use Nexus (Optional)

Nexus is a maven repository manager. You can use Nexus to host your own maven repository for artifact created in your company, or for caching external artifacts.

If you don't have a nexus server in your organisation you can skip this section.

To use Nexus, you will configure Maven to check Nexus instead of the public repositories. To do this, you'll need to edit your settings.xml file.
Maven installation instructions for Ubuntu

<settings></em>

<em> ...</em>

<em> </em>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://your_nexus_host:nexu_port/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
 ...
<settings>

We have defined a single profile: nexus.

The nexus profile is configured to download from the central repository with a bogus URL of http://central. This URL is overridden by the mirror setting in the same settings.xml file to point to the URL of your single Nexus group. The nexus group is then listed as an active profile in the activeProfiles element.

Maven instructions for Ubuntu

<settings>
  ... 
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
  ...
<settings>

If you have any remark or questions feel free to put a comment.If you enjoyed this tutorial and want to promote it don't hesitate to click on

If you are looking for a Maven installation guide for Windows click on the following link :

Maven installation instructions for Windows

Maven Tutorial related articles

Tags: maven , installation , ubuntu , nexus , repository , true , profile , /enabled , enabled , central

Comments

0 #1 learn java programmi 2012-12-30 06:38
Uninstall your current maven 2 before doing this of course.
Quote

Add comment


Security code
Refresh

Java Tutorial on Facebook