Maven Series 3--Maven Command Line Options

It can be reprinted for free, please indicate the source when reprinting   http://pengqb.iteye.com  .


Maven command line options
description:
1. When using the - option, no spaces can be placed between the parameters and the following parameters. When using the -- option, there must be a space between the parameter and the following parameter. Such as the following example:
 $ mvn help:describe -Dcmd=compiler:compile
 $ mvn install --define maven.test.skip=true
2. Some command line options are only available from Maven2.1.

 

define properties
-D, --define<arg> define system properties
This is the most commonly used option to customize the behavior of Maven plugins.

 

get help
-h, --help show help information
If you are looking for information on available goals and parameters for a particular plugin, please refer to the Maven Help plugin.

 

Using Build Profiles
To activate one or more build profiles from the command line, use the following options:
-P, --activate-profiles <arg> Comma-separated list of profiles to activate

 

Displaying version information
To display Maven version information, on the command line, use one of the following options.
-V, --show-version Continue to execute other Maven goals after displaying version information.
-v, --version Display version information.
Both options output the same version information, but the -v option breaks Maven processing after printing the version information. If you want Maven version information to appear at the beginning of the build output, you should use the -V option. The -V option can come in handy if you are running Maven in a continuous build environment and you need to know which Maven version is used for a particular build.

 

Run in offline mode
-o, --offline work in offline mode
This parameter prevents plugins or dependencies from being updated over the network.

Using a custom POM or custom Settings file
If you don't like the pom.xml file name, the location of the user-specific Maven configuration file, or the location of the global configuration file, you can customize these parameters with the options below.
-f, --file <file> force use of alternate POM file
-s, --settings <arg> alternate path to user profile
-gs, --global-settings <file> alternate path to global profile

 

The following commands allow you to encrypt passwords
using Maven and store them in the Maven settings file:
-emp, --encrypt-master-password <password> encrypt master password
-ep, --encrypt-password <password> encrypt server password

 

Failure Handling
The options below control how Maven responds to build failures in the middle of a multi-module project build.
-fae, --fail-at-end only affect build results, allow unaffected builds to continue
-ff, --fail-fast stop on build failures
-fn, --fail-never regardless of project result Build never fails
The -fn and -fae options are useful for multi-module builds using continuous integration tools such as Hunson. The -ff option is useful for developers running interactive builds who want quick feedback during the development cycle.

 

Controlling Maven's log level
If you want to control Maven's log level, you can use the following three command line options:
-e, --errors to generate execution error related messages
-X, --debug to generate execution debugging information
-q, -- quiet only displays errors
The -q option prints a message only if there are errors or problems. The -X option prints a large number of debug log messages, this option is mainly used by Maven developers and Maven plugin developers to diagnose problems with Maven code encountered during development. The -X option is also very useful if you want to diagnose dependency or path problems. The -e option comes in handy if you are a Maven developer, or if you need to diagnose a bug with the Maven plugin. If you want to report an unexpected problem with Maven or the Maven plugin, you should pass the -X and -e command line options.

 

Running Maven
in batch mode To run Maven in batch mode, use the following options:
-B, --batch-mode run in non-interactive (batch) mode
if you need to run in a non-interactive, continuous integration environment Manve, you must use batch mode. Running in non-interactive mode, when Maven needs input, it doesn't stop to accept user input, but uses sensible defaults.

 

Downloading and validating dependencies
The following command-line options affect how Maven interacts with remote repositories and how Maven validates downloaded artifacts:
-C, --strict-checksums Build fails if checksums don't match
-c, --lax- checksums If the checksums do not match, an alarm
-U will be generated. --update-snapshots Force an update when the remote repository updates the release version or snapshot version.
If you are concerned about security, you will want to run Maven with the -C option. The Maven repository maintains an MD5 and SHA1 checksum for each artifact stored in the repository. By default, Maven is configured to alert end users if the checksum of an artifact does not match the downloaded artifact. Passing the -C option will cause the Maven build to fail when an artifact with an incorrect checksum is encountered. The -U option is useful if you want to ensure that Maven checks for the latest version of all snapshot dependencies.

 

Controlling plugin updates
The following command line options tell Maven how it will update (or not) Maven plugins from remote repositories:
-npu, --no-plugin-updates For any related registered plugins, do not check for up-to-dateness. Using this option causes Maven to exhibit stable behavior based on all plugin versions currently available in the local repository.
-cpu, --check-plugin-updates Force up-to-date checks for any relevant registered plugins. Force Maven to check for the latest released version of the Maven plugin, even if the Maven plugin version is explicitly specified in your project POM.
-up, a synonym for --update-plugins cpu.

The following command line options affect how Maven downloads plugins from remote repositories:
-npr, --no-plugin-registry Do not use the configuration in ~/.m2/plugin-registry.xml for plugin versions.
The -npr command line option tells Maven not to refer to the plugin registry. For more information on the plugin registry, go here: http://maven.apache.org/guides/introduction/introduction-to-plugin-registry.html .

 

Non-recursive builds
Sometimes you just want to run Maven builds without getting bogged down in the builds of your project's submodules. You can do this by using the following command line options:
-N, --non-recursive Prevent Maven from building submodules. Only build projects contained in the current directory.
Running this command-line option causes Maven to execute goals or steps in the lifecycle only for projects in the current directory.

 

Reference: "Maven: The Complete Reference"

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326385393&siteId=291194637