littlerobots / version-catalog-update-plugin

Gradle plugin for updating a project version catalog
Apache License 2.0
544 stars 22 forks source link

Plugin section - version.ref is removed and static version is used #119

Open giorgioprovenzale opened 8 months ago

giorgioprovenzale commented 8 months ago

Sometimes I noticed that in the plugin section of the catalog, the version.ref is removed from a plugin and a static version is used.

Here is an example with kotlin:

[versions]
kotlin = "1.9.10"

[plugins]
jetbrains-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }

Then the script suggests this update, instead of updating the kotlin version:

[versions]
kotlin = "1.9.10"

[plugins]
jetbrains-android = "org.jetbrains.kotlin.android:1.9.20"
hvisser commented 8 months ago

In that case there are probably other usages of that version ref that are not updated. Can you confirm that is the case?

giorgioprovenzale commented 8 months ago

yes, that's correct. So we should different version values for plugins and libraries, or do you have some other suggestions?

hvisser commented 8 months ago

Yes or alternatively you could pin the version if you don't want it to update, but generally it means that not all modules update to the same version if this happens, or at least the dependency version plugin is not seeing the updates if they exist. You could try passing --refresh-dependencies to make sure all dependency versions are updated.

JonatanPlesko commented 8 months ago

Hi @hvisser, I experience the same issue even if all of the modules have the same version available. I see it with the following dependencies:

Kotlin 1.9.10 to 1.9.20: org.jetbrains.kotlin:kotlin-stdlib - stays at the previous version despite 1.9.20 being available and removes the reference in the process org.jetbrains.kotlin.android - correctly keeps the version ref and updates to 1.9.20 org.jetbrains.kotlin.plugin.serialization - correctly keeps the version ref and updates to 1.9.20

Detekt 1.23.0 to 1.23.3: io.gitlab.arturbosch.detekt:detekt-formatting - keeps the version reference, but stays at 1.23.0 despite 1.23.3 being available io.gitlab.arturbosch.detekt - removes the version reference and inlines 1.23.3

I can see all of these artifacts sharing the same version when I find them at https://search.maven.org/ I assume the first dependency keeps the ref, and if the next one sharing the same ref finds a different version, it inlines that version. But I don't understand why doesn't the plugin "see" the latest versions as they're available on Maven Central.

hvisser commented 8 months ago

This seems to be an common issue, but resolving of versions is handled by the dependency versions plugin, not this plugin. If the dependency versions plugin doesn't "see" the version then the report produced might have a few updated versions and a few old versions.

If you experience versions that are not "correct" and you can reproduce these I suggest you file an issue for that plugin. Also make sure you try the refresh flag like I mentioned in the previous comment. It's likely some kind of caching issue. So far I have not been able to reproduce issues like this, probably because they resolve after a while, either when maven central updates or caches expire. At least that is my theory right now.

hvisser commented 8 months ago

Also I'm curious if you are using any keep settings. When you keep dependencies that you don't use as an actual dependency, the dependency version plugin won't know about it. As a result it won't be included in the report it generates. This might cause the version catalog update plugin to see a partial update too, breaking the version group as only one of multiple dependencies are updated.

JonatanPlesko commented 8 months ago

I'm not using any keep settings. What you're saying makes sense; I ran the dependency versions plugin independently and I can see that it doesn't detect the latest versions for the aforementioned dependencies. I will try to make a minimal reproducible example and report it there instead.