The various parameters in the plugin configuration provide a means to globally configure the goals, profiles etc. used to run a Maven build on the projects. However, for certain projects you might want to specify different settings. To avoid the hassle of multiple plugin executions, you can simply use a file named invoker.properties to control the build settings on a per project basis. The exact name of this properties file is configurable but it needs to reside in the base directory of the respective project as shown below:
./ +- src/ +- it/ +- test-project/ +- pom.xml +- invoker.properties +- src/
There are only a few keys supported in this file and their names typically match the corresponding parameters in the plugin configuration. The snippet below provides a complete overview of supported properties:
# A comma or space separated list of goals/phases to execute, may # specify an empty list to execute the default goal of the project invoker.goals=clean install # Optionally, a list of goals to run during further invocations of Maven invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run # A comma or space separated list of profiles to activate invoker.profiles=its,jdk15 # The value for the environment variable MAVEN_OPTS invoker.mavenOpts=-Dfile.encoding=UTF-16 -Xms32m -Xmx256m # Possible values are "fail-fast" (default), "fail-at-end" and "fail-never" invoker.failureBehavior=fail-never # The expected result of the build, possible values are "success" (default) and "failure" invoker.buildResult=failure # A boolean value controlling the -N flag, defaults to "false" invoker.nonRecursive=false
The comments given in the example should be rather self-explanatory. Looking closely, you can also notice that the syntax ${expression} can be used to filter the property values. What deserves some more description is the possibility to perform several Maven builds on the same project. By default, the Invoker Plugin will perform the following steps for each project:
Since plugin version 1.3, you can append a one-based index to the invoker properties in order to enable/configure further invocations of Maven. More precisely, invoker.goals.1 specifies the goals for the first build, invoker.goals.2 lists the goals for the second build and so on. These builds will be performed one after the other:
All the properties can be indexed this way, e.g. invoker.profiles.3 would specify the profiles to use for the third invocation. If the property invoker.profiles.3 was not defined, the plugin would query the property invoker.profiles as a fallback to determine the profiles for the third build. This build loop ends after invocation i if the property invoker.goals.i+1 is undefined.