Repository navigation
[Proposal] Standardize Maven POM formatting with Spotless SortPom #5701
Description
Is your feature request related to a problem? Please describe.
Apollo already uses spotless-maven-plugin for Java formatting, and the code-style CI workflow runs mvn spotless:check. However, the current Spotless configuration does not include Maven POM formatting.
The root and module pom.xml files have inconsistent formatting, including a mixture of tabs and spaces, different attribute wrapping, and inconsistent placement of POM elements. For example, the root POM mostly uses tabs while the Spotless configuration uses spaces.
As a result, POM formatting is not checked by the existing code-style workflow, and contributors using different IDE settings can introduce unrelated formatting changes. This creates avoidable diff noise and review work.
This is a focused follow-up to #5480, extending the existing formatting tooling to Maven POM files rather than introducing another standalone formatter.
Describe the solution you would like
Add the following POM formatter configuration alongside the existing <java> section in the root POM's Spotless plugin configuration:
<pom>
<includes>
<include>pom.xml</include>
</includes>
<sortPom>
<expandEmptyElements>false</expandEmptyElements>
</sortPom>
</pom>The inherited configuration would format each module's own pom.xml when Spotless runs across the Maven reactor.
Expected formatting policy
- Use SortPom's default
recommended_2008_06profile to standardize POM element order, including the fields inside individual dependencies and plugins. - Use UTF-8 and two-space indentation.
- Keep empty elements self-closing, for example
<removeUnusedImports/>. - Do not enable sorting dependency lists, plugin lists, properties, modules, or plugin executions. Keep their existing relative order to avoid introducing unnecessary or potentially order-sensitive changes.
- Keep the existing Java formatter and its Eclipse style configuration unchanged. Limit this change to Maven POM files, not arbitrary XML resources.
Implementation and validation outline
- Add the POM formatter configuration to the existing Spotless plugin.
- Run
mvn spotless:applyto establish a consistent baseline for the root and module POM files in a dedicated formatting change, without dependency upgrades or unrelated functional changes. - Review the resulting diff to ensure it consists of formatting, supported POM element reordering, and the formatter configuration itself.
- Run
mvn spotless:check, apply formatting a second time to verify idempotence, and runmvn clean testto check for build regressions. - Clarify in
CONTRIBUTING.mdthat the existing Spotless commands also format/check POM files. The existing CI command should then cover POM formatting without a separate workflow.
Describe alternatives you have considered
- IDE-only formatting: does not provide a shared, CI-enforced result and may vary across contributors' IDE settings.
- A standalone SortPom Maven plugin: would introduce another command/configuration when Spotless already integrates SortPom.
- Whitespace-only formatting: could normalize indentation but would not standardize the placement of POM elements.
Additional context
I have a local draft adding this configuration and normalizing the root and module POM files. Build/test validation is still to be completed before submitting a PR.
The relevant formatting choices are compatible with the Google XML Style Guide: it allows two-space indentation and both self-closing and explicit empty-element forms, and does not prescribe a universal Maven POM element order or a fixed line-length limit.
The Eclipse style file in apollo-buildtools/style configures Java formatting only. The IntelliJ template also contains XML settings, so IDE wrapping/rearrangement can differ from SortPom. Spotless should be the authoritative POM formatter; aligning IDE XML settings can be considered separately to avoid broadening this change.
Activity
github-actions commentedon Oct 23, 2026
Thanks for opening this feature request! The proposal to standardize Maven POM formatting via Spotless SortPom is well-structured and clearly motivated.
This is a great follow-up to #5480, and I appreciate the detailed implementation outline including:
The issue includes all necessary context: problem statement, proposed solution, alternatives considered, and local validation status. Maintainers can proceed with review whenever your draft PR is ready.
A few notes for implementation:
chore: standardize POM formatting with Spotless SortPom (apolloconfig…