-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow disabling version.refs generation #114
Comments
I've run into this as an actual issue: Running the Anyway, since this isn't configurable yet, I applied the following workaround: Workaround// https://github.com/littlerobots/version-catalog-update-plugin/issues/114
tasks.named<VersionCatalogFormatTask>("versionCatalogFormat") {
fun getFile() = catalogFile.asFile.get()
fun File.parse() = inputStream().use { VersionCatalogParser().parse(it) }
var original: VersionCatalog? = null
doFirst { original = getFile().parse() }
doLast {
val file = getFile()
val updated = file.parse()
val addedVersionKeys =
updated.versions.keys.minus(original!!.versions.keys)
.ifEmpty {
return@doLast
}
val fixed =
updated.copy(
libraries =
updated.libraries.mapValues { (_, library) ->
val version = library.version
if (
version is VersionDefinition.Reference &&
version.ref in addedVersionKeys
) {
library.copy(
version =
VersionDefinition.Simple(
(updated.versions.getValue(version.ref)
as VersionDefinition.Simple)
.version
)
)
} else {
library
}
},
plugins =
updated.plugins.mapValues { (_, plugin) ->
val version = plugin.version
if (
version is VersionDefinition.Reference &&
version.ref in addedVersionKeys
) {
plugin.copy(
version =
VersionDefinition.Simple(
(updated.versions.getValue(version.ref)
as VersionDefinition.Simple)
.version
)
)
} else {
plugin
}
},
versions = updated.versions.minus(addedVersionKeys)
)
file.writer().use { VersionCatalogWriter().write(fixed, it) }
}
} A proper upstream change to allow this would probably be to make execution of this line conditional based on some configuration: version-catalog-update-plugin/catalog/src/main/kotlin/nl/littlerobots/vcu/model/VersionCatalog.kt Line 126 in 32f7d9b
|
I'm still not really eager to make this configurable as it adds to the complexity of the plugin (config, testing etc). The generation of version refs is there for convenience but it needs to use a heuristic to do the grouping, since there's no way to know for sure how dependencies are released. I've also observed that most folks want a In this particular case you could do two things:
Though if you feel very strong about making this configurable, I'm happy to take a PR for it. Please add tests too in that case :) I currently don't have the bandwidth to work on it. |
In some cases, the explicit versioning is easier to manage (e.g. with external tooling). It would be good to be able to disable the generation of version.refs and force explicit version strings in the generated entries instead.
The text was updated successfully, but these errors were encountered: