bash-3.2# mvn -v Apache Maven 2.2.0 (r788681; 2009-06-26 06:04:01-0700) Java version: 1.6.0_22 Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home Default locale: en_US, platform encoding: MacRoman OS name: "mac os x" version: "10.6.5" arch: "i386" Family: "mac"To manually upgrade to Maven 3, complete these 3 steps:
- Download Maven 3 archive
- Unpack archive into /usr/share/java/
- Link /usr/share/maven to /usr/share/java/apache-maven-3.0.1
1. Download Maven 3 archive
Go to the Maven download site and download the file named apache-maven-3.0.1-bin.tar.gz to your Desktop.
2. Unpack archive into /usr/share/java/
Open the Terminal. You will need root access to install Maven. Type the following to open a root shell:
sudo bashType your administrator password if prompted. Copy the file that you downloaded in step 1 to the directory where the new Maven will be installed by typing this command:
cp ~/Desktop/apache-maven-3.0.1-bin.tar.gz /usr/share/java/Change to the installation directory by entering this command:
cd /usr/share/java/Unpack the archive, which will create a new directory called apache-maven-3.0.1:
tar xzf apache-maven-3.0.1-bin.tar.gzRemove the archive file - it is no longer needed:
rm apache-maven-3.0.1-bin.tar.gzRemove quarantine status from trusted Maven installation files:
xattr -dr com.apple.quarantine apache-maven-3.0.1/Reduce the permissions on config and JAR files with these commands:
chmod 755 /usr/share/java/apache-maven-3.0.1/conf chmod 644 /usr/share/java/apache-maven-3.0.1/conf/settings.xml chmod 644 /usr/share/java/apache-maven-3.0.1/boot/*.jar chmod 644 /usr/share/java/apache-maven-3.0.1/lib/*.jarAt this point, the new Maven is installed. But the command mvn is still linked to the old installation. The next step will fix this.
3. Link /usr/share/maven to /usr/share/java/apache-maven-3.0.1
Change directories:
cd /usr/shareRemove the link to the old version of Maven:
unlink mavenReplace the old link with a new soft link to the new Maven 3.0 installation:
ln -s java/apache-maven-3.0.1 mavenExit the root session:
exit
Verify Installation
At this point, invoking Maven with the command mvn -v from the Terminal should call the newly installed version:
bash-3.2$ mvn -v Apache Maven 3.0.1 (r1038046; 2010-11-23 02:58:32-0800) Java version: 1.6.0_22 Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home Default locale: en_US, platform encoding: MacRoman OS name: "mac os x" version: "10.6.5" arch: "i386" Family: "mac"After successful installation, the directory structure should be:
/usr/share/maven -> java/apache-maven-3.0.1 /usr/share/java/apache-maven-3.0.1 /usr/share/java/apache-maven-3.0.1/bin /usr/share/java/apache-maven-3.0.1/bin/m2.conf /usr/share/java/apache-maven-3.0.1/bin/mvn /usr/share/java/apache-maven-3.0.1/bin/mvn.bat /usr/share/java/apache-maven-3.0.1/bin/mvnDebug /usr/share/java/apache-maven-3.0.1/bin/mvnDebug.bat /usr/share/java/apache-maven-3.0.1/bin/mvnyjp /usr/share/java/apache-maven-3.0.1/boot /usr/share/java/apache-maven-3.0.1/boot/plexus-classworlds-2.4.jar /usr/share/java/apache-maven-3.0.1/conf /usr/share/java/apache-maven-3.0.1/conf/settings.xml /usr/share/java/apache-maven-3.0.1/lib /usr/share/java/apache-maven-3.0.1/lib/aether-api-1.8.jar /usr/share/java/apache-maven-3.0.1/lib/aether-connector-wagon-1.8.jar /usr/share/java/apache-maven-3.0.1/lib/aether-impl-1.8.jar /usr/share/java/apache-maven-3.0.1/lib/aether-spi-1.8.jar /usr/share/java/apache-maven-3.0.1/lib/aether-util-1.8.jar /usr/share/java/apache-maven-3.0.1/lib/commons-cli-1.2.jar /usr/share/java/apache-maven-3.0.1/lib/maven-aether-provider-3.0.1.jar /usr/share/java/apache-maven-3.0.1/lib/maven-artifact-3.0.1.jar /usr/share/java/apache-maven-3.0.1/lib/maven-compat-3.0.1.jar /usr/share/java/apache-maven-3.0.1/lib/maven-core-3.0.1.jar /usr/share/java/apache-maven-3.0.1/lib/maven-embedder-3.0.1.jar /usr/share/java/apache-maven-3.0.1/lib/maven-model-3.0.1.jar /usr/share/java/apache-maven-3.0.1/lib/maven-model-builder-3.0.1.jar /usr/share/java/apache-maven-3.0.1/lib/maven-plugin-api-3.0.1.jar /usr/share/java/apache-maven-3.0.1/lib/maven-repository-metadata-3.0.1.jar /usr/share/java/apache-maven-3.0.1/lib/maven-settings-3.0.1.jar /usr/share/java/apache-maven-3.0.1/lib/maven-settings-builder-3.0.1.jar /usr/share/java/apache-maven-3.0.1/lib/nekohtml-1.9.6.2.jar /usr/share/java/apache-maven-3.0.1/lib/plexus-cipher-1.4.jar /usr/share/java/apache-maven-3.0.1/lib/plexus-component-annotations-1.5.5.jar /usr/share/java/apache-maven-3.0.1/lib/plexus-interpolation-1.14.jar /usr/share/java/apache-maven-3.0.1/lib/plexus-sec-dispatcher-1.3.jar /usr/share/java/apache-maven-3.0.1/lib/plexus-utils-2.0.4.jar /usr/share/java/apache-maven-3.0.1/lib/sisu-guice-2.9.1-noaop.jar /usr/share/java/apache-maven-3.0.1/lib/sisu-inject-bean-1.4.3.1.jar /usr/share/java/apache-maven-3.0.1/lib/sisu-inject-plexus-1.4.3.1.jar /usr/share/java/apache-maven-3.0.1/lib/wagon-file-1.0-beta-7.jar /usr/share/java/apache-maven-3.0.1/lib/wagon-http-lightweight-1.0-beta-7.jar /usr/share/java/apache-maven-3.0.1/lib/wagon-http-shared-1.0-beta-7.jar /usr/share/java/apache-maven-3.0.1/lib/wagon-provider-api-1.0-beta-7.jar /usr/share/java/apache-maven-3.0.1/lib/xercesMinimal-1.9.6.2.jar /usr/share/java/apache-maven-3.0.1/LICENSE.txt /usr/share/java/apache-maven-3.0.1/NOTICE.txt /usr/share/java/apache-maven-3.0.1/README.txtThe Windows .bat files in the bin directory are not needed, but they don't hurt anything. The original archive downloaded to the Desktop can be safely removed now that Maven was upgraded successfully.
Alternative Installation Methods
If you are already using MacPorts, you can upgrade Maven using this simple command:
sudo port install maven3If you wish to install MacPorts, check the MacPorts installation page for more information. There are .dmg disk images available for Snow Leopard that make installation very easy.
Thanks for the guide; it came in handy to night when I didn't have time to fiddle with trying to get it set up properly!
ReplyDeleteThank you very much, it worked like a charm!
ReplyDeleteGerhard
Thanks a lot, they should include this in the official maven docs :-)
ReplyDeleteIt's also possible to use the homebrew packaging system (https://github.com/mxcl/homebrew). And do a "brew install maven"
ReplyDeleteGreat Post! Also works for 3.0.3 :)
ReplyDeleteThanks!! It works well.
ReplyDeleteYes I confirm it does work like charm, for 3.0.4 too
ReplyDelete