refreshVersions
refreshVersions copied to clipboard
Please keep order and format of version catalog
I just have applied and run refreshVersions
.
This mixed up my existing version catalog which was written in the idiomatic way.
It put the plugins
section first and put newlines between the headings and the content.
Please either keep the format that is currently present or if you insist on reformatting the whole file, then please do it in the idiomatic way suggested by the Gradle documentation.
That is the order versions
, libraries
, bundles
, and finally plugins
without empty lines between title and content like
[versions]
groovy = "3.0.5"
checkstyle = "8.37"
[libraries]
groovy-core = { module = "org.codehaus.groovy:groovy", version.ref = "groovy" }
groovy-json = { module = "org.codehaus.groovy:groovy-json", version.ref = "groovy" }
groovy-nio = { module = "org.codehaus.groovy:groovy-nio", version.ref = "groovy" }
commons-lang3 = { group = "org.apache.commons", name = "commons-lang3", version = { strictly = "[3.8, 4.0[", prefer="3.9" } }
[bundles]
groovy = ["groovy-core", "groovy-json", "groovy-nio"]
[plugins]
jmh = { id = "me.champeau.jmh", version = "0.6.5" }
Here a work-around:
gradle.rootProject {
tasks.configureEach {
if (name == "refreshVersions") {
doLast {
file("gradle/libs.versions.toml").apply {
readText()
.replace("]\n\n", "]\n")
.replace("""(?s)^(.*)(\n\Q[plugins]\E[^\[]*)(\n.*)$""".toRegex(), "$1$3$2")
.also { writeText(it) }
}
}
}
}
}