Purpose
This preset adds the ability for Renovate to suggest upgrades to the Scalafmt version set in Maven Spotless plugin.
As Renovate natively supports upgrading version in the Scalafmt configuration file, this preset will include the changes to the pom.xml
file in the same PR/MR as the .scalafmt.conf
file.
Example
This preset will suggest changes similar to the following:
pom.xml:
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.46.1</version>
<configuration>
<scala>
<scalafmt>
- <version>3.9.7</version>
+ <version>3.9.8</version>
<file>${project.basedir}/.scalafmt.conf</file>
</scalafmt>
</scala>
</configuration>
</plugin>
Preset
preset.json5:
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"description": "Configure Renovate to suggest upgrades to the Scalafmt version set in Spotless plugin parameters. In same PR as .scalafmt.conf file.",
"customManagers": [
{
"customType": "regex",
// Where to look for (pom.xml)
"managerFilePatterns": ["/(^|/)pom\\.xml$/"],
// What to look for and extract from the pom.xml
"matchStrings": [
"<scalafmt>\\s*<version>(?<currentValue>.*?)<\\/version>"
],
// Using same settings as scalafmt manager
// Especially the depName so that the upgrade is part of the same PR as .scalafmt.conf file
// See https://github.com/renovatebot/renovate/blob/main/lib/modules/manager/scalafmt/extract.ts#L18 for reference
"depNameTemplate": "scalafmt",
"datasourceTemplate": "github-releases",
"packageNameTemplate": "scalameta/scalafmt",
"extractVersionTemplate": "^v(?<version>\\S+)",
"versioningTemplate": "semver"
}
]
}
Other presets
Check out other useful presets.