Skip to content

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

Merged
khatchad merged 2 commits into
wala:masterfrom
ponder-lab:chore/spotless-prefs-multi-module-path
Apr 30, 2026
Merged

Use ${maven.multiModuleProjectDirectory}/spotless.xml.prefs for robust resolution#432
khatchad merged 2 commits into
wala:masterfrom
ponder-lab:chore/spotless-prefs-multi-module-path

Conversation

@khatchad
Copy link
Copy Markdown
Collaborator

@khatchad khatchad commented Apr 29, 2026

Problem

pom.xml line 233 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. When Maven is run from the multi-module root (the typical case), this works. But it can fail when invoked 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.prefs from those contexts.

Fix

Use ${maven.multiModuleProjectDirectory}, which always points at the directory containing the topmost parent POM regardless of how Maven is invoked:

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

Verification

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

Both pass after the change. The submodule-targeted invocation is the case where the relative path was fragile.

…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.

Verified `mvn spotless:check` and
`mvn -pl ml/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:02
@khatchad khatchad enabled auto-merge (squash) April 29, 2026 14:02
Copy link
Copy Markdown
Contributor

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

This PR makes the Spotless Eclipse WTP XML formatter prefs file reference resilient to Maven’s invocation directory by switching from a relative path to ${maven.multiModuleProjectDirectory}.

Changes:

  • Update Spotless eclipseWtp prefs file path to ${maven.multiModuleProjectDirectory}/spotless.xml.prefs to avoid CWD-dependent resolution.

Comment thread pom.xml
@khatchad
Copy link
Copy Markdown
Collaborator Author

Heads-up for reviewers: the failing build check on this PR is inherited from upstream master, not caused by the path change. Master has been red since 810fe5d (the exec-maven-plugin 3.5.1→3.6.1 bump, #336) — the actual failure is dependency-resolution for com.ibm.wala:*:1.6.13-SNAPSHOT, which has nothing to do with this one-line config change.

Filed #433 tracking the master-CI breakage with timeline data and suggested fixes.

Once master is restored, this PR's checks should go green and automerge will fire — no rebase needed on this side.

@khatchad khatchad merged commit 2238db3 into wala:master Apr 30, 2026
1 check passed
@khatchad khatchad deleted the chore/spotless-prefs-multi-module-path branch April 30, 2026 03:53
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.91%. Comparing base (e9f72e6) to head (e5185f1).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #432   +/-   ##
=========================================
  Coverage     57.91%   57.91%           
  Complexity      624      624           
=========================================
  Files           111      111           
  Lines          7671     7671           
  Branches        856      856           
=========================================
  Hits           4443     4443           
  Misses         3050     3050           
  Partials        178      178           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

4 participants