According to maven POM reference , we can define multiple <configuration>
tag for maven plugins.
<plugin>
<groupId/>
<artifactId/>
<version/>
<extensions/>
<executions>
<execution>
<id/>
<phase/>
<goals/>
<inherited/>
<configuration/>
</execution>
</executions>
<dependencies>
...
</dependencies>
<goals/>
<inherited/>
<configuration/>
</plugin>
If you can see one <configuration>
is inside the <execution>
tag and other outside. Let us take an example to see it more clearly :
Example :
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<include>**/*Tests.java</include>
<include>**/*Test.java</include>
</includes>
<excludes>
<exclude>**/Abstract*.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
<configuration>
<includes>
<include>**/*Tests.java</include>
<include>**/*Test.java</include>
</includes>
<excludes>
<exclude>**/Abstract*.java</exclude>
</excludes>
</configuration>
</plugin>
Consider the following surefire plugin . It has 2 <configuration>
. One is inside the <execution>
and other outside.
What is the difference between the two ? Please explain in general terms and not just for surefire plugin example. Is the outside something like global configuration ?
One is global configuration, the other is execution-specific configuration
The global applies whenever nothing else overrides it. When you call a goal of a plugin (as in your example), it doesn't refer to any specific execution, so it will use the global configuration
But keep in mind some plugins do declare a default execution and bind it to some phase - that may interfere with configuration resolution when invoking a phase instead of a goal.