it may not be appropriate for all goals in the plugin to take this configuration. This is a common problem with the Compiler plugin, where you may want different parameters for the compile and testCompile goals (such as the JDK level – a problem well known by TestNG users developing on JDK 1.4!)

you can’t erase configuration through inheritance – so as the example above shows, you are stuck with those excludes even if you define a new goal to run a second set of tests

Maven 2.2 adds a simple solution to this problem – all of the executions in the default lifecycle are assigned IDs of the form default-phase. Because Maven’s inheritance merges executions with identcial IDs, you can assign configuration directly to the built in goal and no others.

This means that the previous section can be reduced back closer to the original, like so:

The goals are not necessary in the execution, since they were already given in the default binding.

This results in a more intuitive pattern for setting up multiple test executions (a common occurrence with profiles and integration tests), as well as use cases such as configuration the compiler plugin goals separately.

One more thing to watch out for – taking advantage of this will mean the build is no longer compatible with earlier versions of Maven. To make sure you don’t get caught out, you should add the Enforcer plugin somewhere in the build:

In addition to changing the defaults, you can also now supply configuration that is targeted at command line invocations (without affecting the main build). More information on all of these can be found in the new Guide to Configuring Default Execution IDs.

Book

Coverage of intermediate Apache Maven concepts with a focus on best practices and "tying it all together". Significant coverage of automated build and repository management concepts, illustrated using Apache Continuum and Apache Archiva.