Scrivio Interview library
InternalsIntermediate7 min read · updated 12 November 2026

Explain pluginManagement versus plugins in Maven, and why builds that rely on default plugin versions are a problem.

pluginManagement in a parent only declares plugin versions and default configuration; a plugin actually runs only when it is listed in <plugins> or bound to the lifecycle by the packaging. Builds that rely on default plugin versions are a problem because those versions come from the Maven installation, its super POM and default lifecycle bindings, so upgrading Maven silently changes the plugins and the build. We should pin every plugin version, usually in a parent POM's pluginManagement, enforce it with the Enforcer rule requirePluginVersions, and know that executions are merged by id while combine.children and combine.self control how configuration is merged.

Background to this question

Plugin configuration is where Maven builds hide most of their surprises: a plugin that is configured but never runs, a build that behaves differently on a colleague's machine, a test plugin that suddenly finds no tests after a Maven upgrade. All of them come from how Maven decides which plugins run, which version, and with which configuration. In this answer, we will compare pluginManagement and plugins, see where default versions come from and why they are a problem, pin and enforce versions, and then look inside the merging of executions and configuration between parent and child.

1PluginManagement Versus plugins

Both elements live under build and look the same: plugin entries with groupId, artifactId, version, configuration and executions. The difference is the same as between dependencyManagement and dependencies. Entries in plugins are plugins this project uses: their goals are added to the build and run when their phase is reached. Entries in pluginManagement are only defaults: they say which version and configuration to use if and when this plugin is used, here or in any child that inherits this POM.

A plugin from pluginManagement takes effect in two ways. Either a module lists it in its own plugins section, often with just groupId and artifactId, and gets the managed version and configuration. Or the plugin is already part of the build through the packaging's default lifecycle bindings, such as maven-compiler-plugin and maven-surefire-plugin for a jar, and the managed version and configuration apply to those bindings too.

XML
<!-- parent: decide versions and defaults -->
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version> <!-- example version -->
<configuration><failIfNoSpecifiedTests>false</failIfNoSpecifiedTests></configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<!-- child jar module, no <plugins> section -->
<!-- surefire 3.5.2 runs: it is bound to the test phase by jar packaging -->
<!-- jacoco does NOT run: it is only managed, nobody listed it in <plugins> -->
Step throughDoes a plugin run in this module?
  1. Listed in this module's effective <plugins>?
    Yesit runs, using managed version and config if presentNonext check
  2. Bound by the packaging's default lifecycle?
    Yesit runs, managed version and config applyNoit does not run: pluginManagement alone does nothing

2 steps in order. Play them, or step through them one at a time.

This is the most common confusion: someone adds JaCoCo to the parent's pluginManagement and wonders why there is no coverage report. Managed plugins that are not part of the default lifecycle need to be listed in plugins, in the parent if every module should run them, or in the modules that need them.

2Where Default Plugin Versions Come From

When a plugin is used without a version, Maven still needs one. For plugins bound by the default lifecycle, such as compiler, surefire, jar and install, the versions come from the Maven distribution itself: its super POM, the implicit parent of every POM, and its definition of the default lifecycle bindings. Each Maven release ships its own set of these versions.

So two developers with different Maven versions build the same POM with different plugin versions. Upgrading Maven on the CI agent changes the compiler plugin or Surefire behind everyone's back. Plugin defaults do change between versions: Surefire versions have changed how tests are discovered and how JUnit Platform is detected, and compiler plugin defaults for source and target levels have changed over the years. The build is not reproducible, and when it breaks, nothing in the repository's history explains why.

For plugins listed in plugins without a version and not bound by default, Maven 3 resolves a version from the repository metadata and prints a warning that the version is missing and that future Maven versions may no longer support such builds. That is even less stable, because the result can change whenever a new plugin version is published. Maven 4 is stricter in several of these areas, so check the version in use.

3Pinning Versions and Enforcing It

The fix is to pin every plugin version explicitly, including the default lifecycle ones, in one place: the parent POM's pluginManagement. Then the Maven version only decides how Maven itself works, not which plugins run. To make sure nobody adds an unpinned plugin later, the Maven Enforcer plugin's requirePluginVersions rule fails the build when any plugin in use has no explicit version.

XML
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.5.0</version> <!-- check the current version -->
<executions>
<execution>
<id>enforce-plugin-versions</id>
<goals><goal>enforce</goal></goals>
<configuration>
<rules>
<requirePluginVersions/>
<requireMavenVersion><version>[3.9,)</version></requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<!-- [ERROR] Rule 0: requirePluginVersions failed: Some plugins are missing valid versions: -->
<!-- org.apache.maven.plugins:maven-site-plugin -->

requireMavenVersion is a useful companion, because some plugin versions need a minimum Maven version. The Maven wrapper, mvnw with a pinned Maven version in .mvn/wrapper, completes the picture by making every machine use the same Maven.

4How Executions Are Merged

Plugin configuration in a child is merged with the inherited and managed configuration, not simply replaced. Executions are merged by their id. If the parent defines an execution with id report and the child declares an execution with the same id, the child's settings are merged into it; with a different id, the child adds a second execution and both run. Default lifecycle bindings have well-known ids such as default-compile and default-test, which is how we change the configuration of a default binding or disable it by setting its phase to none.

XML
<!-- child: same id as the parent's execution, so it is merged, still one execution -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>report</id>
<phase>verify</phase>
</execution>
</executions>
</plugin>
<!-- change a default lifecycle binding through its well-known id -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>default-test</id>
<configuration><excludedGroups>slow</excludedGroups></configuration>
</execution>
</executions>
</plugin>

5Combine.children and combine.self

Inside configuration, Maven merges elements by name, and list-like elements are not appended by default: the child's entries overlay the parent's, so a child that adds one compiler argument can lose the inherited ones, which often surprises people. Two attributes control this. combine.children="append" on an element tells Maven to append the child's entries after the parent's instead of merging them by position. combine.self="override" tells Maven to replace the parent's element completely with the child's, ignoring what was inherited.

XML
<!-- parent -->
<compilerArgs><arg>-Xlint:all</arg></compilerArgs>
<!-- child, default merge: not appended; the child's arg overlays the parent's (check with help:effective-pom) -->
<compilerArgs><arg>-parameters</arg></compilerArgs>
<!-- child, append: effective list is -Xlint:all, -parameters -->
<compilerArgs combine.children="append"><arg>-parameters</arg></compilerArgs>
<!-- child, override: effective list is only -parameters -->
<compilerArgs combine.self="override"><arg>-parameters</arg></compilerArgs>

Because merging rules are subtle, the reliable way to know what a module really runs is mvn help:effective-pom, which prints the fully merged POM, with -Dverbose to show where each line came from.

6Follow-up questions

Why not put every plugin directly in the parent's <plugins>?

Because then every module runs every plugin, including modules where it makes no sense, such as a code coverage check in a module without code, or packaging plugins in a pom module. pluginManagement lets the parent decide versions and defaults centrally while modules opt in to what they use. The parent's plugins section is for the few plugins that really apply everywhere, such as the Enforcer.

Does pluginManagement apply to plugins bound by packaging?

Yes. A managed version and configuration for maven-surefire-plugin applies to the surefire:test goal that jar packaging binds to the test phase, even though no module lists Surefire in its plugins section.

How do you see which plugin versions a build actually uses?

mvn help:effective-pom shows the merged build section with versions. The build log also prints each goal with its version, such as surefire:3.5.2:test, and the versions plugin's display-plugin-updates goal lists plugins whose versions are missing or outdated.

7Conclusion

In this answer, we saw that pluginManagement only declares versions and default configuration, while a plugin runs only when it is listed in <plugins> or bound by the packaging. Without explicit versions, default lifecycle plugins take their versions from the Maven installation, so upgrading Maven silently changes the build, and unbound plugins may even resolve the latest release. Pinning every version in a parent's pluginManagement, enforced by requirePluginVersions and the Maven wrapper, makes builds reproducible, and understanding that executions merge by id and that combine.children and combine.self control configuration merging explains what each module really runs.

What to say in the interviewAbout 90 seconds aloud

Open with

pluginManagement works like dependencyManagement for plugins. In a parent it declares versions and default configuration, but it does not make anything run. A plugin runs in a module only if it is in that module's effective plugins section, or if the packaging binds it to the lifecycle, like the compiler, Surefire and jar plugins for a jar.

Then, if they want more

So putting JaCoCo only in pluginManagement gives no report until someone lists it in plugins, while a managed Surefire version does apply to the default test binding. The problem with default versions is that they come from the Maven installation, its super POM and default lifecycle bindings.

Two machines with different Maven versions then run different plugin versions, and upgrading Maven on CI silently changes the build, and plugin defaults really do change between versions. Plugins listed without a version and not bound by default are worse, because Maven 3 resolves them from repository metadata with a warning.

So I pin every plugin version, including the default ones, in the parent's pluginManagement, enforce it with the Enforcer rule requirePluginVersions, and pin Maven itself with the wrapper.

For inheritance details, executions are merged by id, which is how a child changes default-compile or default-test, and combine.children append or combine.self override control how configuration lists merge. help:effective-pom shows the final result.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Apache Maven guides
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain pluginManagement versus plugins in Maven, and why builds that rely on default...": https://scrivio-interview-library.netlify.app/java/maven/a448bfb476/