Maven
Install¶
Install Maven using SDKMAN with the following command:
Wrapper¶
The Maven Wrapper is an excellent tool to ensure that all developers use the same version of Maven. It is a set of files that you can commit to your project, and it will download the correct version of Maven when you run it.
To create the Maven Wrapper, run the following command:
We can also specify the version of Maven to use:
Note: The option
-N
means non-recursive, and it tells Maven to execute the command only in the current project and not in the modules.
Usage¶
Build¶
To build a project, run the following command:
To skip the tests, run the following command:
Test¶
To run test in a project, run the following command:
Debug¶
To debug a Maven build, run the following command:
Verify¶
To verify mvn package is valid and meets quality criteria of a project, run the following command:
Package¶
To package a project, run the following command:
Deploy¶
To deploy a project, run the following command:
Release¶
To release a project, run the following command:
Upgrade wrapper¶
To upgrade the Maven Wrapper, run the following command:
Update dependencies¶
To display the new versions of the dependencies in a project, run the following command:
To update the dependencies in a project, run the following command:
To display the new versions of the plugins in a project, run the following command:
Tips & tricks¶
Skip tests¶
To skip the tests during the build, run the following command:
Reduce verbosity¶
To reduce the verbosity of the Maven output, run the following command:
Sometimes you may notice output like this:
Downloading: http://.../artifactory/repo/com/codahale/metrics/metrics-core/3.0.1/metrics-core-3.0.1.jar
4/2122 KB
8/2122 KB
12/2122 KB
16/2122 KB
18/2122 KB
18/2122 KB 4/480 KB
18/2122 KB 8/480 KB
18/2122 KB 12/480 KB
18/2122 KB 16/480 KB
18/2122 KB 16/480 KB 4/1181 KB
18/2122 KB 16/480 KB 8/1181 KB
18/2122 KB 16/480 KB 12/1181 KB
To reduce the verbosity of the download progress, run the following command: