Download
Download maven from: http://maven.apache.org/download.cgi
Choose the Binary tar.gz archive, and extract it with tar xzvf apache-maven-3.3.9-bin.tar.gz
Edit the environment PATH
vim /etc/profile
Insert:
export MAV_HOME="/home/apache-maven-3.3.9"
export PATH="$MAV_HOME/bin:$PATH"
Save and update the profile
source /etc/profile
Confirm setup:
mvn -v
Succeed if some appears like this:
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /home/apache-maven-3.3.9
Java version: 1.8.0_111, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_111/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.8.0-41-generic", arch: "amd64", family: "unix"
Quick Use
clean workspace: mvn clean
compile and test: mvn install
skip tests: mvn install -DskipTests
skip test execution but compile: mvn install -Dmaven.test.skip.exec=true
clean and test: mvn clean install
run selected test after compile: mvn test -Dtest=TestClassName (combined: mvn clean install -Dtest=TestClassName)
create runnable binaries after install: mvn assembly:assembly -Pnative (combined: mvn clean install assembly:assembly -Pnative)
Done! Enjoy!