While the most popular way to run Maven is to specify goals, Maven provides a number of command-line options to customize its behavior. They range from specifying values for properties, to varying the verbosity of the Maven output. It is useful to know some of the arguments, as they will often help with troubleshooting issues with Maven.
To understand command-line options in Maven, perform the following steps:
mvn –h
A number of options that Maven supports are displayed in the preceding screenshot.
We will briefly discuss the command-line options that Maven provides.
When there is an error while running Maven, this flag will result in Maven displaying a detailed stack trace of the error:
-e –errors
When the quiet
option is enabled, only errors are displayed. The other outputs are not printed. This permits speeding up builds where verbose outputs are usually displayed:
-q –quiet
We have seen the version
option to display the Maven version in the first three recipes of Chapter 1, Getting Started. This is also a simple way to check if Maven is installed and working:
-v –version
When invoked with the offline
option, Maven does not attempt to download any dependency or plugin from the Internet. This option will work correctly, provided Maven has all the information required for the project to be built and run. We will see how to enable projects to run in offline mode:
-o –offline
When enabled with the debug
option, Maven prints a lot of verbose output about every step that it performs. This is typically used to troubleshoot any build issues:
-X –debug
18.224.56.29