bash-3.2# mvn -v Apache Maven 2.2.0 (r788681; 2009-06-26 06:04:01-0700) Java version: 1.6.0_20 Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home Default locale: en_US, platform encoding: MacRoman OS name: "mac os x" version: "10.6.4" arch: "i386" Family: "macTo manually upgrade to Maven 2.2.1, complete these 3 steps:
- Download Maven 2.2.1 archive
- Unpack archive into /usr/share/java/
- Link /usr/share/maven to /usr/share/java/apache-maven-2.2.1
1. Download Maven 2.2.1 archive
Go to the Maven download site and download the file named apache-maven-2.2.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-2.2.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-2.2.1:
tar xzf apache-maven-2.2.1-bin.tar.gzRemove the archive file - it is no longer needed:
rm apache-maven-2.2.1-bin.tar.gzRemove quarantine status from trusted Maven installation files:
xattr -dr com.apple.quarantine apache-maven-2.2.1/If the mvn or mvnDebug binaries are not already executable (they should be), you can make sure they are with these commands:
chmod 755 /usr/share/java/apache-maven-2.2.1/bin/mvn chmod 755 /usr/share/java/apache-maven-2.2.1/bin/mvnDebugAt 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-2.2.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 2.2.1 installation:
ln -s java/apache-maven-2.2.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 2.2.1 (r801777; 2009-08-06 12:16:01-0700) Java version: 1.6.0_20 Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home Default locale: en_US, platform encoding: MacRoman OS name: "mac os x" version: "10.6.4" arch: "i386" Family: "mac"After successful installation, the directory structure should be:
/usr/share/maven@ -> java/apache-maven-2.2.1 /usr/share/java/apache-maven-2.2.1/ /usr/share/java/apache-maven-2.2.1/bin/ /usr/share/java/apache-maven-2.2.1/bin/m2.conf /usr/share/java/apache-maven-2.2.1/bin/mvn /usr/share/java/apache-maven-2.2.1/bin/mvn.bat /usr/share/java/apache-maven-2.2.1/bin/mvnDebug /usr/share/java/apache-maven-2.2.1/bin/mvnDebug.bat /usr/share/java/apache-maven-2.2.1/boot/ /usr/share/java/apache-maven-2.2.1/boot/classworlds-1.1.jar /usr/share/java/apache-maven-2.2.1/conf/ /usr/share/java/apache-maven-2.2.1/conf/settings.xml /usr/share/java/apache-maven-2.2.1/lib/ /usr/share/java/apache-maven-2.2.1/lib/maven-2.2.1-uber.jar /usr/share/java/apache-maven-2.2.1/LICENSE.txt /usr/share/java/apache-maven-2.2.1/NOTICE.txt /usr/share/java/apache-maven-2.2.1/README.txtThe .bat files in the bin directory are not really 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 maven2If you wish to install MacPorts, check the MacPorts installation page for more information about installing MacPorts. There are .dmg disk images available for Snow Leopard that make installation very easy.
Thank you for this tutorial. It's now updated on my mac!
ReplyDeletethank you, this was very straight forward and easy!
ReplyDeletethnx man!
ReplyDeletedidn't work for me :(
ReplyDeletemvn still invokes maven 2.2.0
something with the link I assume...
oh, it *does* work. it was just the modifications that the liftweb installer had made to .bash_profile that overrode the link. thanks for your instructions! :)
ReplyDeleteFor instructions on upgrading to Maven 3.0, check my updated post.
ReplyDeleteThanks so much!
ReplyDeleteInstruction are simple and easy to install maven.I must thank for your blog
ReplyDeleteLife saver!!
ReplyDelete