Maven Command Line Reference

本文详细介绍了Maven命令行中可用的选项及其用途,包括定义系统属性、使用Emacs、帮助信息、输出异常堆栈跟踪等。通过理解这些选项,开发者可以更高效地进行项目构建和管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The following command line options are available when running Maven:

usage: maven [options] [goal [goal2 [goal3] ...]]

Options:
 -D,--define arg    Define a system property
 -E,--emacs         Produce logging information without adornments
 -P,--plugin-help   Display help on using a given plugin
 -X,--debug         Produce execution debug output
 -b,--nobanner      Suppress logo banner
 -d,--dir arg       Set effective working directory (ignored with -p or -f)
 -e,--exception     Produce exception stack traces
 -f,--find arg      Set project file and effective working directory by finding
                    the project file
 -g,--goals         Display available goals
 -h,--help          Display help information
 -i,--info          Display system information
 -o,--offline       Build is happening offline
 -p,--pom arg       Set project file
 -q,--quiet         Reduce execution output
 -u,--usage         Display help on using the current project
 -v,--version       Display version information

Typically, Maven is run with a list of goals in the order they should be executed. If no goals are specified, the default goal specified inmaven.xml file. Additionally, the following switches can be specified. Note that -P-g-h-i-u and -v cause Maven to exit immediately without running any goals given.

OptionUsage
-DDefines a system property. This will take priority over any other property specified. eg. maven -Dmaven.repo.remote=http://public.planetmirror.com/pub/maven.
-EOutput messages without adornments, making it more suitable for use in emacs.
-PGet help with plugins. When used without any arguments, ie. maven -P, all installed plugins are listed with a description. When a plugin name is given, the goals in that plugin are listed. eg. maven -g jar lists the goals such as jar:jar,jar:install, and so on.
-XOutput full debugging information while performing the build. This can be helpful in tracing what is happening inside a plugin, or sending information to the Maven Developers about an internal bug.
-bDon't show the ASCII Art banner.
-dSet the effective working directory for running Maven in.
-eDisplay the stack trace for any final exception that leads to a build failure.
-fSet the effective working directory for running Maven in by searching for the closest project.xml.
-gList all goals available, both in this project and all installed plugins. Best used with grep or a pager such as less.
-hList the help commands above.
-iShow system information. Lists environment properties such as the Java version, all installed plugins and their versions, and the user's build.properties file.
-oRun in offline mode. This is equivalent to specifying the property maven.mode.online=false. Missing dependencies will cause failures, however old SNAPSHOTs will only cause a warning.
-pSpecify the project file to use. By default it is project.xml in the current directory.
-qRun in quiet mode. Only errors are output. Note that some plugins do not honour this option, so it should not be considered as a silent mode.
-uShow the usage instructions for the current project. This will include the goals specified in maven.xml, and the instructions listed in the description element of the project.
-vShow the Maven version and exit.

MAVEN_OPTS

Specify additional options using the MAVEN_OPTS environment variable. It is for passing parameters to the Java VM when running Maven. For example, to increase the amount of memory to 1024 Meg for the entire run of Maven, use:

MAVEN_OPTS=-Xmx1024m

Also note that a given plug-in may have a property to set for its memory usage, such as the Javadoc plug-in'smaven.javadoc.maxmemory property. This is because that particular plugin forks an additional Java VM.

For another example, set the MAVEN_OPTS to run Java in debug mode:

MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y

After setting this property, run "maven cactus:test" (or whatever goal to debug) and it will block, waiting for a debug connection.

Then, in your IDE, select the "Run -> Debug" window and craete a new "Remote Java Application" configuration, passing the port set in MAVEN_OPTS (8787 in this case).

Once running this configuration in debug, the blocked Maven session will continue, enabling debugging from your IDE.

转载于:https://my.oschina.net/aiguozhe/blog/35700

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值