Skip to content

feat: read scalafmt version from scalafmt config if not provided#2922

Merged
nedtwigg merged 3 commits into
diffplug:mainfrom
jozic:feat/get-scalafmt-version-from-scalafmt-config
May 14, 2026
Merged

feat: read scalafmt version from scalafmt config if not provided#2922
nedtwigg merged 3 commits into
diffplug:mainfrom
jozic:feat/get-scalafmt-version-from-scalafmt-config

Conversation

@jozic
Copy link
Copy Markdown
Contributor

@jozic jozic commented May 10, 2026

Motivation

Scalafmt config files already carry a version field (e.g. version = 3.8.1) and it is mandatory. Requiring users to also declare the version in their Spotless plugin config is redundant and a source of inconsistency.

Change

When no explicit scalafmt version is configured in the plugin, Spotless now reads it from the scalafmt config file. Only if the config file is absent or has no version field (which is invalid) it falls back to the built-in default (3.8.1). If a version is explicitly set in the plugin config, it takes precedence and the existing mismatch check still applies (to keep it all backward compatible).

Scope

The resolution logic lives in lib (ScalaFmtStep), so both the Maven and Gradle plugins benefit automatically. Both plugins were updated to pass null when no version is explicitly configured, and some tests were added for both.

@jozic
Copy link
Copy Markdown
Contributor Author

jozic commented May 14, 2026

@nedtwigg could you please check this PR out?
Thank you!

…sion-from-scalafmt-config

# Conflicts:
#	CHANGES.md
#	plugin-gradle/CHANGES.md
#	plugin-maven/CHANGES.md
@nedtwigg nedtwigg merged commit 3b6401d into diffplug:main May 14, 2026
20 checks passed
@jozic jozic deleted the feat/get-scalafmt-version-from-scalafmt-config branch May 15, 2026 00:03
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