Homebrew Maven
The installation of Apache Maven is a simple process of extracting the archive and adding the `bin` folder with the `mvn` command to the `PATH`.
- Brew untap of an official tap you don’t use (e.g. Homebrew/homebrew-cask) will ensure it’s no longer automatically retapped; brew casks is a new command implemented in Bash to speedily output all casks available to install (like brew formulae) brew info -cask -json=v2 includes whether a cask is outdated and the currently installed versions.
- The Maven compiler accepts this command with – target and – source versions. If we want to use the Java 8 language features, the – source should be set to 1.8. Also, for the compiled classes to be compatible with JVM 1.8, the – target value should be 1.8. The default value for both of them is the 1.6 version.
- Lately I had to update Maven on a OSX developer machine an thought it might be worth to record this low frequency task for the future. Our show case: Upgrading Maven from 3.1.1 to 3.2.5. Get your local brewery up to date in case you sparsely use it like I do.
You can install maven using Homebrew. It is fairly straight forward. If you do not have Homebrew installed on your mac, you can use below command to install it. /bin/bash -c “$ (curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)”.
Detailed steps are:
Ensure
JAVA_HOME
environment variable is set and points to your JDK installationExtract distribution archive in any directory
or
Alternatively use your preferred archive extraction tool.
Add the
bin
directory of the created directoryapache-maven-3.8.1
to thePATH
environment variableConfirm with
mvn -v
in a new shell. The result should look similar to
Windows Tips
- Check environment variable value e.g.
Homebrew Maven Settings.xml
Adding to
PATH
: Add the unpacked distribution’s bin directory to your user PATH environment variable by opening up the system properties (WinKey + Pause), selecting the “Advanced” tab, and the “Environment Variables” button, then adding or selecting the PATH variable in the user variables with the valueC:Program Filesapache-maven-3.8.1bin
. The same dialog can be used to setJAVA_HOME
to the location of your JDK, e.g.C:Program FilesJavajdk1.7.0_51
Open a new command prompt (Winkey + R then type
cmd
) and runmvn -v
to verify the installation.
Unix-based Operating System (Linux, Solaris and Mac OS X) Tips
Homebrew Maven Without Openjdk
- Check environment variable value
Homebrew Maven Update
- Adding to
PATH