Hi, I’m using the Gradle plugin `id("org.jlleitsch...
# ktlint
b
Hi, I’m using the Gradle plugin
id("org.jlleitschuh.gradle.ktlint")
to format my kotlin sources. The plugin’s configuration extension does allow me to configure the Ktlint version to be used but I wonder whether I can achieve the same with dependency managment? Ideally I would like Renovate Bot to raise an PR when a new Ktlint version is available. Is that feasible at all? Thanks
w
I am not familiar with Renovate bot, but the plugin applies ktlint as a regular dependency to a custom configuration under the hood. So any gradle-based dependency check tool should be able to detect that. It may not be able to generate the fix PR, but should be able to alert you
b
Currently I do this in my `build.gradle.kts`:
Copy code
configure<KtlintExtension> {
     version.set("0.50.0")
}
My point is that Renovate Bot (or equivalent) does not see above version “0.50.0" as a regular dependency. (like
api()
and
implementation()
dependencies) What I’m hoping to do is to set the Ktlint version to be used by the Gradle plugin like this:
Copy code
dependencies {
    ktlintRuleset("com.pinterest.ktlint:ktlint-ruleset-standard:1.0.1")
}
With above fragment, Renovate Bot will consider that a regular dependency with GAV coordinates and automatically create a PR whenever a new version of Ktlint is available. Unfortunately above
ktlintRuleset()
dependency does not yield the same outcome as
version.set("1.0.1")
m
Not sure if that's helpful, but I saw: https://github.com/PaulWoitaschek/Voice/pull/2134/files, which contained a ktlint version bumped, so renovate was able to recognise the version somehow. AFAIK they only consume the version taken from
libs
extension, so maybe having a dummy entry in the toml file is enough (source):
Copy code
ktlint-core = { module = "com.pinterest.ktlint:ktlint-cli", version.ref = "ktlint-core" }
👀 1
w
Yeah that is probably the way to go. although the plugin applies the dependencies under the hood, it also uses the extension property directly to choose different implementations of code that interacts with ktlint, so you need to make sure that the property is set properly. using a version catalog version reference would work
b
Thanks for your suggestions folks.
184 Views