Use ${maven.multiModuleProjectDirectory}/spotless.xml.prefs for robust resolution#188
Use ${maven.multiModuleProjectDirectory}/spotless.xml.prefs for robust resolution#188khatchad wants to merge 1 commit into
${maven.multiModuleProjectDirectory}/spotless.xml.prefs for robust resolution#188Conversation
…ust resolution
The relative `./spotless.xml.prefs` path resolves correctly when Maven
is invoked from the multi-module root, but can fail when invoked from
elsewhere (e.g., a submodule's `basedir`, an IDE's per-module run, or
nested Maven invocations). Switching to the
`${maven.multiModuleProjectDirectory}` property — which always points
at the directory containing the parent `pom.xml` — makes resolution
robust regardless of invocation context.
Matches the pattern downstream consumers like
`ponder-lab/Hybridize-Functions-Refactoring` already use for the same
file. Verified `mvn spotless:check` and
`mvn -pl com.ibm.wala.cast.python.ml spotless:check` both succeed
after the change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates the Spotless XML formatter configuration to resolve spotless.xml.prefs via Maven’s multi-module root directory, making formatting checks more reliable across different Maven invocation contexts (root vs submodule, IDE runs, nested builds).
Changes:
- Replace relative Spotless prefs path (
./spotless.xml.prefs) with${maven.multiModuleProjectDirectory}/spotless.xml.prefsfor stable resolution.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <type>XML</type> | ||
| <files> | ||
| <file>./spotless.xml.prefs</file> | ||
| <file>${maven.multiModuleProjectDirectory}/spotless.xml.prefs</file> |
There was a problem hiding this comment.
${maven.multiModuleProjectDirectory} is only available in newer Maven versions (introduced in Maven 3.3.1). If someone runs this build with an older Maven, interpolation will fail and Spotless config parsing can break. Consider adding a Maven Enforcer rule (or documenting the minimum supported Maven version) so failures are explicit and easier to diagnose.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #188 +/- ##
=========================================
Coverage 68.29% 68.29%
Complexity 2069 2069
=========================================
Files 196 196
Lines 17133 17133
Branches 2839 2839
=========================================
Hits 11701 11701
Misses 4320 4320
Partials 1112 1112 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Problem
The XML format block in
pom.xmlreferences the Spotless prefs file with a relative path:```xml
XML
./spotless.xml.prefs
```
Relative paths resolve against Maven's current working directory at invocation time. When Maven is run from the multi-module root (the typical case), this works. But it can fail when run from elsewhere — a submodule's
basedir, an IDE's per-module test run, or a nested Maven invocation — because the file isn't at./spotless.xml.prefsfrom those contexts.Fix
Use `${maven.multiModuleProjectDirectory}`, which always points at the directory containing the topmost parent POM regardless of how Maven is invoked:
```xml
${maven.multiModuleProjectDirectory}/spotless.xml.prefs
```
Same pattern downstream consumers like `ponder-lab/Hybridize-Functions-Refactoring` already use for the same file. Cross-repo consistency.
Verification
```
$ mvn spotless:check # from root: BUILD SUCCESS
$ mvn -pl com.ibm.wala.cast.python.ml spotless:check # from root targeting submodule: BUILD SUCCESS
```
Both pass after the change. The submodule-targeted invocation in particular is the case where the relative path was fragile.