chapter
Maven is a powerful build tool for Java projects, based on POM (Project Object Model) file that can be used to build the project, dependent on module management and Javadoc generation.
What is the build tool
Build software build process automation tool is a tool. Building a software project usually contains the following sections:
- Generating source code (if used to automatically generate the project source code)
- Generating a document from source code (e.g. Javadoc)
- Compile the source code
- The compiled code or ZIP package to package JAR package
- The deployment of packaged file to the server or repository
Some software project may also contain other special building tasks that can be added to the build process in maven automated execution.
Build process automation benefit is to avoid making mistakes, more efficient, manual process of building relatively slow and error-prone.
Maven's official website
Maven can be downloaded from the official website
Installing Maven
Installation steps are as follows:
- Set the
JAVA_HOME
environment variable, pointing to Java SDK (eg Java 8) installation directory. - Download Maven and unzip to the specified directory, this directory is the maven installation directory.
- Set the
M2_HOME
environment variable, pointing to the unpacked Maven directory. - Set
M2
environment variables, point to the bin directory of the Maven extract the directory (on Windows%M2_HOME%\bin
, on UNIX$M2_HOME/bin
). - Will
M2
add an environment variable to the PATH environment variable (on Windows% M2%, on unix as $ M2). - Verify the installation, execute the command line
mvn -version
.
Execute mvn -version
command output maven if the version number is correct, the installation was successful.
Note: Depending on Maven Java runtime, the system needs to be installed Jdk (and JAVA_HOME environment variables) can not be used JRE, maven need to use the Java compiler, JRE is not included.