Configuring Maven plugins :
Maven plugins are configured broadly in two ways.
- Global configuration : This configuration applies to all the goals of a plugin.
- Execution specific configuration : Configuration is binded to a specific goals and phases.
Global Configuration :
To apply configuration for all the goals of a plugin follow the syntax shown in following XML. In this example we set compiler version to 1.6 (default is 1.5) which applies to all the goals of compiler plugin (such as compiler:compile, compiler:testCompile etc.)
Execution Specific Configuration :
In advanced build process we may require to execute a plugin with certain configurations for a certain execution. Say for the first execution we need to compile with 1.3 compiler version and for the second execution we need to compile with 1.5 compiler version. This is shown in following XML.
Another use case could be binding the configuration to specific goal and phase as shows below. In this case for antrun plugin configuration is binded to validation phase and run goal .
NOTE: Global Plugin configurations are overriden/merged by more specific execution plugin configuration
P.S. To find all the goals and default configuration of a plugin(say compiler plugin) type mvn help:describe -Dplugin=compiler -Ddetail .
No comments:
Post a Comment