Maven Tips and Tricks: Describing Maven Plugins With help:describe
By Tim OBrien
3 minute read time
If you do any non-trivial customization of a Maven build, you'll understand that you need to have a good understanding of Maven Plugin configuration. What configuration parameters are available for a particular plugin goal? Most users tend to Google for the particular Maven plugin and rely on the fact that most Maven-generate plugin sites contain a standard list of goals and configuration parameters. While this works, there is a better way: use the Maven Help plugin's describe goal to list the available configuration parameters for a Maven plugin.
Describing Plugin Configuration Parameters with a Command
<?xml version="1.0"?> $ mvn help:describe -Dcmd=compiler:compile [INFO] [help:describe {execution: default-cli}] [INFO] 'compiler:compile' is a plugin goal (aka mojo). Mojo: 'compiler:compile' compiler:compile Description: Compiles application sources Deprecated. No reason given
Sure, the compile goal in the compiler plugin will compile application sources. That's not exactly what you were looking for, what you usually need is a detailed list of plugin configuration parameters. You can get this by passing in a -Ddetail argument.
$mvn help:describe -Dcmd=compiler:compile -Ddetail [INFO] [help:describe {execution: default-cli}] [INFO] 'compiler:compile' is a plugin goal (aka mojo). Mojo: 'compiler:compile' compiler:compile Description: Compiles application sources Deprecated. No reason given Implementation: org.apache.maven.plugin.CompilerMojo Language: java Bound to phase: compile Available parameters: compilerArgument Sets the unformatted argument string to be passed to the compiler if fork is set to true. This is because the list of valid arguments passed to a Java compiler varies based on the compiler version. Deprecated. No reason given compilerArguments Sets the arguments to be passed to the compiler (prepending a dash) if fork is set to true. This is because the list of valid arguments passed to a Java compiler varies based on the compiler version. Deprecated. No reason given compilerId (Default: javac) The compiler id of the compiler to use. See this guide for more information. Deprecated. No reason given compilerVersion Version of the compiler to use, ex. '1.3', '1.5', if fork is set to true. Deprecated. No reason given debug (Default: true) Set to true to include debugging information in the compiled class files. Deprecated. No reason given encoding The -encoding argument for the Java compiler. Deprecated. No reason given excludes A list of exclusion filters for the compiler. Deprecated. No reason given executable Sets the executable of the compiler to use when fork is true. Deprecated. No reason given failOnError (Default: true) Indicates whether the build will continue even if there are compilation errors; defaults to true. Deprecated. No reason given fork (Default: false) Allows running the compiler in a separate process. If 'false' it uses the built in compiler, while if 'true' it will use an executable. Deprecated. No reason given includes A list of inclusion filters for the compiler. Deprecated. No reason given maxmem Sets the maximum size, in megabytes, of the memory allocation pool, ex. '128', '128m' if fork is set to true. Deprecated. No reason given meminitial Initial size, in megabytes, of the memory allocation pool, ex. '64', '64m' if fork is set to true. Deprecated. No reason given optimize (Default: false) Set to true to optimize the compiled code using the compiler's optimization methods. Deprecated. No reason given outputFileName Sets the name of the output file when compiling a set of sources to a single file. Deprecated. No reason given showDeprecation (Default: false) Sets whether to show source locations where deprecated APIs are used. Deprecated. No reason given showWarnings (Default: false) Set to true to show compilation warnings. Deprecated. No reason given source The -source argument for the Java compiler. Deprecated. No reason given staleMillis (Default: 0) Sets the granularity in milliseconds of the last modification date for testing whether a source needs recompilation. Deprecated. No reason given target The -target argument for the Java compiler. Deprecated. No reason given verbose (Default: false) Set to true to show messages about what the compiler is doing. Deprecated. No reason given
That's more like it. If you ever find yourself wondering what a particular plugin configuration parameter's name is, or what a default value for a parameter is. You now know how to find it. For more information see the Configuring Maven chapter in Maven: The Definitive Guide.
Written by Tim OBrien
Tim is a Software Architect with experience in all aspects of software development from project inception to developing scaleable production architectures for large-scale systems during critical, high-risk events such as Black Friday. He has helped many organizations ranging from small startups to Fortune 100 companies take a more strategic approach to adopting and evaluating technology and managing the risks associated with change.
Explore All Posts by Tim OBrien