Reputation: 365
Let's consider the following parent POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.example</groupId>
<artifactId>imaginary-plugin</artifactId>
<version>1.0</version>
<configuration>
<whatever>111</whatever>
</configuration>
<inherited>false</inherited>
</plugin>
<plugin>
<groupId>com.example</groupId>
<artifactId>imaginary-plugin-exec</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>whatever</id>
<goals>
<goal>whatever</goal>
</goals>
<inherited>false</inherited>
</execution>
</executions>
<configuration>
<whatever>111</whatever>
</configuration>
<inherited>false</inherited>
</plugin>
</plugins>
</pluginManagement>
<!-- same as above, for the sake of example -->
<plugins>
<plugin>
<groupId>com.example</groupId>
<artifactId>imaginary-plugin</artifactId>
<version>1.0</version>
<configuration>
<whatever>111</whatever>
</configuration>
</plugin>
<plugin>
<groupId>com.example</groupId>
<artifactId>imaginary-plugin-exec</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>whatever</id>
<goals>
<goal>whatever</goal>
</goals>
</execution>
</executions>
<configuration>
<whatever>111</whatever>
</configuration>
<inherited>false</inherited>
</plugin>
</plugins>
</build>
</project>
We have two non-existing plugins for one of which (imaginary-plugin-exec
) we have executions defined
Now let's add a child POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>parent</artifactId>
<groupId>org.example</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<artifactId>child</artifactId>
</project>
When we get effective POM for the child (mvn help:effective-pom
), we get the following pluginManagement
and plugins
:
<pluginManagement>
<plugins>
<!-- a bunch of default plugin configs, skipped for clarity -->
<plugin>
<groupId>com.example</groupId>
<artifactId>imaginary-plugin-exec</artifactId>
<version>1.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.example</groupId>
<artifactId>imaginary-plugin-exec</artifactId>
<version>1.0</version>
</plugin>
<!-- a bunch of default plugin configs, skipped for clarity -->
</plugins>
As we can see, imaginary-plugin-exec
appears in the effective POM even though it has inherited set to false in parent POM. Yet it does not have any configuration (so disabling inheritance partially works). What is the reason for that behavior and is there a way to avoid it?
As a random attempt to solve it I tried to set <inherited>false</inherited>
for execution, but it did not help.
Upvotes: 1
Views: 1091
Reputation: 298
The description of <inherited>
element says:
Whether any configuration should be propagated to child POMs.
The same information, worded slightly different, can be found on the page which means that <inherited>
can only be used to stop the inheritance of the plugin configuration but not the plugin itself.
Upvotes: 1