Invoker Properties

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 or in one of its ancestor folders to apply it for a group of projects. 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/
      +- group-1
         +- invoker.properties
         +- 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. For a complete overview of supported properties, see the example given in the documentation of the plugin parameter invokerPropertiesFile.

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:

  • Run the pre build hook script if existent
  • Invoke Maven in the project directory
  • Run the post build hook script if existent

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:

  • Run the pre build hook script if existent
  • Invoke Maven in the project directory
  • Invoke Maven in the project directory
  • ...
  • Invoke Maven in the project directory
  • Run the post build hook script if existent

Most of 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 no property invoker.*.i+1 is defined.

The invoker properties can also be used to skip projects based on the current JRE version or OS family. For more information on this feature, please see Selector Conditions.