Quick revision
The short answer
I would move the shared configuration into a versioned corporate parent POM: pluginManagement with pinned versions for compiler, Surefire, JaCoCo, Spotless and Enforcer, plus the few plugins every service should run. The parent stays small and stable, because every change forces all services to rebuild and retest, and it exposes properties such as a coverage threshold as the documented extension points teams may override. Logic that does not fit configuration becomes a tested Maven plugin or extension rather than antrun scripts, and changes roll out through update bots and a changelog, with the parent tested against sample projects in its own pipeline.
What to remember
In this answer, we replaced 150 copied lines with a versioned corporate parent that pins plugin versions in pluginManagement and runs the shared quality plugins. The parent stays small and stable, with library versions in a separate BOM, and exposes properties such as coverage.minimum as its supported extension points. Logic goes into a tested Maven plugin or extension instead of antrun scripts, and every change is tested against sample projects in the parent's own pipeline and rolled out with a changelog and update bots.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would move the shared configuration into a versioned corporate parent POM: pluginManagement with pinned versions for compiler, Surefire, JaCoCo, Spotless and Enforcer, plus the few plugins every service should run. The parent stays small and stable, because every change forces all services to rebuild and retest, and it exposes properties such as a coverage threshold as the documented extension points teams may override. Logic that does not fit configuration becomes a tested Maven plugin or extension rather than antrun scripts, and changes roll out through update bots and a changelog, with the parent tested against sample projects in its own pipeline.
Why this question is asked
Copying 150 lines of plugin configuration into every service works on day one and decays from day two. Each copy drifts: one team bumps JaCoCo, another changes the Spotless rules, a third forgets the Enforcer, and soon nobody knows which configuration is the real one or why builds behave differently. Interviewers ask this design question at senior level because the technical answer, a parent POM, is easy, while the hard part is designing it so that it can evolve for years without blocking teams. In this answer, we will design the parent, decide what stays out of it, define extension points, handle logic that configuration cannot express, and plan how changes are tested and rolled out.
1A Versioned Corporate Parent
A parent POM is a pom-packaged artifact that other POMs name in their parent element and inherit from. We publish it like any library, with its own version, for example com.example:service-parent:4.2.0, to the internal repository. Each service changes its parent to it and deletes its copied block.
The parent contains two kinds of plugin configuration. pluginManagement pins the versions and default configuration of every plugin the services use, including the default lifecycle ones, so builds no longer depend on the Maven version. The plugins section lists the few plugins every service should run, such as the Enforcer, JaCoCo and Spotless, so services get them without writing anything. If services already inherit from spring-boot-starter-parent, the corporate parent can itself inherit from it, so the services keep Boot's build defaults.
Plugin versions here are examples. A service's POM shrinks from 150 lines of plugins to a parent element and perhaps one property.
2Keeping the Parent Small and Stable
A parent is inherited by every service, so every change to it is a change to every build. If the parent changes weekly, every service must rebuild, retest and review an upgrade weekly, and teams start ignoring upgrades. So the parent should contain only what really is common, the build conventions, and should change rarely and deliberately.
Library versions in particular do not belong here; they change much more often and belong in a separate BOM that the parent imports. That way a security fix to a library is a BOM release and does not touch the build conventions. Anything only some services need, such as a code generator or a container image plugin, stays in those services or in an opt-in profile, rather than becoming a switch every service inherits.
- Service POMparent reference, its own dependencies, overrides of documented properties
- Corporate parent (changes rarely)plugin versions, shared plugin config, quality gates
- Platform BOM (changes often)library versions, imported by the parent
- Maven plugin or extension (when needed)tested Java code for logic configuration cannot express
4 layers, from the top down. Step through them one at a time.
Different change rates, different artifacts.
3Properties as Extension Points
Teams will need to adjust some settings: a legacy service may need a lower coverage threshold for a while, a library may target a different Java version. If the only way to change something is to copy and override a whole plugin block, we are back to copies that drift. Instead, the parent reads the adjustable values from properties, as with coverage.minimum above, and documents them as the supported extension points.
A team then writes one line in its own properties, such as coverage.minimum 0.55, and inherits everything else. The list of supported properties is short and documented in the parent's README, and anything not exposed as a property is a conscious decision that the setting should be the same everywhere. A report across repositories showing which properties each service overrides tells the platform team where the defaults are wrong.
4Logic That Does Not Fit Configuration
Sometimes the copied block contains logic: an antrun script that checks file headers, a shell call that generates a version file, conditional steps expressed with profiles and properties. That kind of logic is hard to read in XML, impossible to unit test, and breaks in ways that are hard to debug.
When a shared build step needs real logic, I would write it as a small Maven plugin, a Java class implementing a goal, called a Mojo, packaged and versioned like any library, with unit tests and integration tests run with the maven-invoker-plugin against sample projects. For behaviour that must change how Maven itself works, such as adjusting the project model before the build, a Maven core extension is the tool, but it is more powerful and more fragile, so it is rarely the first choice. Either way, the parent then contains one short plugin declaration instead of 40 lines of script.
5Testing and Rolling Out Changes
The parent needs its own pipeline. It keeps a few sample projects that represent typical services, such as a web service, a library and a batch job. Every change to the parent builds those samples with the new parent and checks the expected results: tests run, coverage is enforced, formatting violations fail, Enforcer rules trigger. A change that would break all services is then caught once, in one pipeline.
Releases come with a changelog that says what changed and whether a service must do anything, for example a new Enforcer rule that may need fixes. Renovate or Dependabot then open pull requests in every service to move to the new parent version, and each service's CI shows whether it passes. Breaking changes, such as raising the minimum Java version, get a major version, advance notice and a migration note, and the previous major version stays supported for a stated period.
- Change the parente.g. bump Surefire, add an Enforcer rule
- Build sample projects with itweb service, library, batch job
- Samples behave as expected?Yesrelease with a changelogNofix before anyone is affected
- Bots open upgrade PRs in every serviceeach service's CI decides
- Track adoption and support older versionsfor a stated window
5 steps in order. Play them, or step through them one at a time.
6Follow-up questions
What if a team cannot use the corporate parent because it already has a parent?
Then the parent is not the only route. The versions part can be consumed through the BOM by import, and the build conventions can be offered as a parent that itself inherits from the common base, such as spring-boot-starter-parent. In the rare remaining cases, the team copies a minimal block, but the Enforcer rules and the quality gates should still come from a shared, versioned source, such as a shared Enforcer rules artifact.
Are Maven tiles or mixins an option?
Tiles, a third-party extension, let a project combine several pieces of build configuration without a single inheritance chain, and newer Maven versions discuss similar mixin ideas. They solve the one-parent limit, but add a less familiar mechanism, so I would use them only if the single parent truly does not fit, and check the support in the Maven version in use.
How do you stop the parent from growing back into a dumping ground?
Give it an owner, a review rule that every addition must apply to most services, and a regular cleanup. Anything specific to a few services goes into an opt-in profile, a separate plugin, or the services themselves.
7Conclusion
In this answer, we replaced 150 copied lines with a versioned corporate parent that pins plugin versions in pluginManagement and runs the shared quality plugins. The parent stays small and stable, with library versions in a separate BOM, and exposes properties such as coverage.minimum as its supported extension points. Logic goes into a tested Maven plugin or extension instead of antrun scripts, and every change is tested against sample projects in the parent's own pipeline and rolled out with a changelog and update bots.
Open with
I would turn the copied block into a versioned corporate parent POM, published like any other artifact. Its pluginManagement pins versions and default configuration for the compiler, Surefire, Failsafe, JaCoCo, Spotless and Enforcer, and its plugins section activates the few that every service should run, so a service's POM shrinks to a parent reference.
Then, if they want more
If services use Spring Boot, the corporate parent can inherit from spring-boot-starter-parent so they keep Boot's defaults. I would keep the parent small and stable, because every change forces every service to rebuild and retest; library versions go into a separate BOM that changes more often.
Teams get properties as documented extension points, for example coverage.minimum for the JaCoCo threshold or the Java version, so they can adjust one value without copying a block. Anything with real logic, like the antrun scripts people tend to accumulate, becomes a small Maven plugin with unit and invoker tests, or in rare cases a core extension.
For evolution, the parent has its own pipeline that builds a few sample projects with every change, releases come with a changelog and semantic versions, breaking changes like a new minimum Java version get a major release and notice, and Renovate or Dependabot open the upgrade pull requests in all services so each one's CI shows whether it is ready.
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 "Several teams copy the same 150 lines of plugin configuration (compiler, Surefire...": https://scrivio-interview-library.netlify.app/java/maven/60759cac18/