Tuesday, January 22, 2019

Updating to Maven 3.6.0

On Ubuntu 16.04

Default state:
  • installation directory is: /usr/share/maven
  • version is 3.3.9
Update to new version (following the official, and this and this linux specific tutorials):
  1. download newest version of maven (bin tar.gz) from https://maven.apache.org/download.cgi
  2. unpack to /opt folder (the folder for installing unbundled independent applications)
    sudo tar xvf apache-maven-*.tar.gz --directory /opt
  3. add environmental variables (see also: official reference):
    1. create script file to set the variables system wide:
      sudo gedit /etc/profile.d/maven.sh
    2. add these lines and save it (change jdk path if needed):
      ## Environmental variables needed by Maven
      export JAVA_HOME=/usr/lib/jvm/jdk-11.0.2/
    3. set the file executable
      sudo chmod +x /etc/profile.d/maven.sh
    4. log out and log in again to see its effect
  4. update alternatives for the specific new version (change path if needed)
    sudo update-alternatives --install "/usr/bin/mvn" "mvn" "/opt/apache-maven-3.6.0/bin/mvn" 100
    sudo update-alternatives --set mvn /opt/apache-maven-3.6.0/bin/mvn
Note: With the above approach, the M2_HOME and MAVEN_HOME environmental variables are not needed, and the bin folder doesn't have to be added to the PATH manually.

On Windows 10

  1. download newest version of maven (bin zip) from https://maven.apache.org/download.cgi
  2. unpack zip to "C:\Program Files\Apache\"
  3. add "C:\Program Files\Apache\apache-maven-3.6.0\bin\" to Path environmental variable, or replace older maven version in Path variable with new one
  4. log out and log in for the environmental variable to take effect
Note: the M2_HOME and MAVEN_HOME environmental variables are not needed.

No comments:

Post a Comment