Maven 2 Installation (Unix, Linux and Mac OS)

Maven Download and Setup

1.Download Maven from here, http://maven.apache.org/download.html.  Download version 2.0.9 or higher.

2.Unzip the contents and place it in a folder such as /Users/peterlong/usr/Java.

3.Create a, or edit your existing, .bash_profile in your home directory (~) so that it includes the following

export M2_HOME=/Users/peterlong/usr/Java/apache-maven-2.0.9

export M2=$M2_HOME/bin

export M2_REPO=/Users/.m2/repository

export MAVEN_OPTS=’-XX:MaxPermSize=128m -Xmx512m’

export JAVA_HOME=/Library/Java/Home/

export PATH=$PATH:$M2

Testing the Maven Installation

1.Open a terminal window.

2.Create a temporary project directory, say ~/usr/java/test

3.cd to the directory and test the execution of the maven command with

mvn --version

Something similar to the following should have been produced.

Maven version: 2.0.9

Java version: 1.5.0_16

OS name: "mac os x" version: "10.5.6" arch: "i386" Family: "unix"

4.If this is successful, test the creation of a temporary project, by issuing the following

mvn archetype:create -DgroupId=testapp -DartifactId=testapp

After a minute or so you should see

[INFO] -----------------------------------------------------------

[INFO] Using following parameters for creating OldArchetype: maven-archetype-quickstart:RELEASE

[INFO] -----------------------------------------------------------

[INFO] Parameter: groupId, Value: testapp

[INFO] Parameter: packageName, Value: testapp

[INFO] Parameter: basedir, Value: /Users/peterlong/usr/java/test

[INFO] Parameter: package, Value: testapp

[INFO] Parameter: version, Value: 1.0-SNAPSHOT

[INFO] Parameter: artifactId, Value: testapp

[INFO] ********************* End of debug info from resources from generated POM ***********************

[INFO] OldArchetype created in dir: /Users/peterlong/usr/java/test/testapp

[INFO] -----------------------------------------------------------

[INFO] BUILD SUCCESSFUL

[INFO] -----------------------------------------------------------

[INFO] Total time: 1 minute 6 seconds

[INFO] Finished at: Wed Jan 28 16:47:17 GMT 2009

[INFO] Final Memory: 7M/14M

[INFO] -----------------------------------------------------------

5.Check that you got BUILD SUCCESSFUL and that a testapp directory was set up containing the corresponding project files.

6.Delete the test directory when you are finished as you have successfully set up the Maven environment.  Return to Building Bluprint.