Skip to content

Use ${maven.multiModuleProjectDirectory}/spotless.xml.prefs for robust resolution#189

Merged
khatchad merged 1 commit into
masterfrom
chore/spotless-prefs-multi-module-path-fork
Apr 29, 2026
Merged

Use ${maven.multiModuleProjectDirectory}/spotless.xml.prefs for robust resolution#189
khatchad merged 1 commit into
masterfrom
chore/spotless-prefs-multi-module-path-fork

Conversation

@khatchad
Copy link
Copy Markdown
Member

@khatchad khatchad commented Apr 29, 2026

Re-opening of #188, which was inadvertently closed when its branch (chore/spotless-prefs-multi-module-path) was deleted during cleanup of a sibling upstream PR. Same content, new branch (-fork suffix to disambiguate from the upstream-targeted PR's branch of the same prefix).

Problem

pom.xml references the Spotless prefs file with a relative path:

<eclipseWtp>
  <type>XML</type>
  <files>
    <file>./spotless.xml.prefs</file>
  </files>
</eclipseWtp>

Relative paths resolve against Maven's current working directory at invocation time. Works from the multi-module root but can fail from elsewhere — submodule's basedir, IDE's per-module run, nested Maven invocation.

Fix

Use ${maven.multiModuleProjectDirectory} for invocation-context-independent resolution:

<file>${maven.multiModuleProjectDirectory}/spotless.xml.prefs</file>

Same pattern downstream consumers like ponder-lab/Hybridize-Functions-Refactoring already use.

Verification

$ mvn spotless:check                                       # from root: BUILD SUCCESS
$ mvn -pl com.ibm.wala.cast.python.ml spotless:check       # submodule-targeted: BUILD SUCCESS

Related

…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>
Copilot AI review requested due to automatic review settings April 29, 2026 14:12
@khatchad khatchad enabled auto-merge April 29, 2026 14:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Maven Spotless configuration to reference the shared Eclipse WTP formatting prefs via Maven’s multi-module root directory, making formatting checks more robust across different invocation contexts in this multi-module build.

Changes:

  • Switch Spotless eclipseWtp XML prefs path from a relative path (./spotless.xml.prefs) to ${maven.multiModuleProjectDirectory}/spotless.xml.prefs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pom.xml
@khatchad khatchad merged commit 5c2c60a into master Apr 29, 2026
26 of 28 checks passed
@khatchad khatchad deleted the chore/spotless-prefs-multi-module-path-fork branch April 29, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants