Skip to content

Declare formatter version to avoid spotless choosing a version#681

Merged
MarkEWaite merged 1 commit intojenkinsci:masterfrom
MarkEWaite:declare-palantir-version-to-reduce-JDK-variation
Jun 26, 2025
Merged

Declare formatter version to avoid spotless choosing a version#681
MarkEWaite merged 1 commit intojenkinsci:masterfrom
MarkEWaite:declare-palantir-version-to-reduce-JDK-variation

Conversation

@MarkEWaite
Copy link
Contributor

@MarkEWaite MarkEWaite commented Jun 8, 2025

Declare formatter version to avoid spotless choosing a version

diffplug/spotless#2503 (comment) indicates that spotless chooses a formatter version based on the JDK running the formatting process. We intentionally run our tests with both JDK 17 and JDK 21. In some source code, that causes source code formatting to fail the build on one JDK version when it passes on the other JDK version.

Examples of the failure and workarounds that have been applied:

Matching pull request in plugin pom:

Testing done

In this repository:

mvn clean install versions:display-plugin-updates

In the winstone repository (where we saw the issue):

Reverted the change that made the formatting independent of Java version in b95111923002d82598d4d85f67f40fa6170dda5e and then added explicit spotless version definition to the pom file so that I could confirm that changing Java versions does not change the formatting.

MarkEWaite/winstone@78ea965 has the details

. ~/bin/use_java17
mvn spotless:apply
git status
. ~/bin/use_java21
mvn spotless:apply
git status

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

diffplug/spotless#2503 (comment)
indicates that spotless chooses a formatter version based on the JDK
running the formatting process.  The spotless maintainer recommends that
we declare a formatter version explicitly so that the formatter won't
change based on the JDK version.

Testing done:

In this repository:

mvn clean install versions:display-plugin-updates

In the winstone repository (where we saw the issue):

Reverted the change that made the formatting independent of Java version
in b95111923002d82598d4d85f67f40fa6170dda5e and then added explicit
spotless version definition to the pom file so that I could confirm that
changing Java versions does not change the formatting.

MarkEWaite/winstone@78ea965
has the details

. ~/bin/use_java17
mvn spotless:apply
git status

. ~/bin/use_java21
mvn spotless:apply
git status

Matching pull request in plugin pom:

* jenkinsci/plugin-pom#1151
@MarkEWaite MarkEWaite merged commit 44ad9f5 into jenkinsci:master Jun 26, 2025
2 checks passed
@MarkEWaite MarkEWaite deleted the declare-palantir-version-to-reduce-JDK-variation branch July 1, 2025 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants