|Maven: The Complete Reference
- 6.1. Maven Command Line Options
The following sections detail Maven’s command line options.
To define a property use the following option on the command line:
This is the option most frequently used to customized the behavior of
Maven plugins. Some examples of using the
$ mvn help:describe -Dcmd=compiler:compile $ mvn install -Dmaven.test.skip=true
Properties defined on the command line are also available as properties to be used in a Maven POM or Maven Plugin. Form more information about referencing Maven properties, see Chapter 9, Properties and Resource Filtering.
Properties can also be used to activate build profiles. For more information about Maven build profiles, see Chapter 5, Build Profiles.
To list the available command line parameters, use the following command line option:
Executing Maven with this option produces the following output:
$ mvn --help usage: mvn [options] [<goal(s)>] [<phase(s)>] Options: -am,--also-makeIf project list is specified, also build projects required by the list -amd,--also-make-dependentsIf project list is specified, also build projects that depend on projects on the list -B,--batch-modeRun in non-interactive (batch) mode ...
If you are looking for information about the goals and parameters available from a specific Maven plugin, see Section 6.3, “Using the Maven Help Plugin”.
To activate one or more build profiles from the command line, use the following option:
For more information about build profiles, see Chapter 5, Build Profiles.
To display Maven version information, use one of the following options on the command line:
Both of these options produce the same version information output, but the -v option will terminate the Maven process after printing out the version. You would use the -V option if you wanted to have the Maven version information present at the beginning of your build’s output. This can come in handy if you are running Maven in a continuous build environment and you need to know what version of Maven was used for a particular build.
Maven Version Information.
$ mvn -v Apache Maven 2.2.1 (r801777; 2009-08-06 14:16:01-0500) Java version: 1.6.0_15 Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home Default locale: en_US, platform encoding: MacRoman OS name: "mac os x" version: "10.6.1" arch: "x86_64" Family: "mac"
If you ever need to use Maven without having access to a network, you should use the following option to prevent any attempt to check for updates to plugins or dependencies over a network:
When running with the offline option enabled, Maven will not attempt to connect to a remote repository to retrieve artifacts.
If you don’t like the pom.xml file name, the location of your user-specific Maven settings, or the default location of your global settings file, you can customize any of these things with the following options:
The following commands allow you to use Maven to encrypt passwords for storage in a Maven settings file:
Encrypting passwords is documented in Section 15.2.11, “Encrypting Passwords in Maven Settings”.
The following options control how Maven reacts to a build failure in the middle of a multi-module project build:
If you want to control Maven’s logging level, you can use one of the following three command line options:
To run Maven in batch mode use the following option:
Batch mode is essential if you need to run Maven in a non-interactive, continuous integration environment. When running in non-interactive mode, Maven will never stop to accept input from the user. Instead, it will use sensible default values when it requires input.
The following command line options affect the way that Maven will interact with remote repositories and how it verifies downloaded artifacts:
If you are concerned about security, you will want to run Maven with
There will be times when you simply want to run a Maven build without having Maven descend into all of a project’s submodules. You can do this by using the following command line option:
Running this will only cause Maven to execute a goal or step through
the lifecycle for the project in the current directory. Maven will not
attempt to build all of the projects in a multi-module project when
you use the