rejectVersionIf not utilized for catalog library entry
mluckam opened this issue · 4 comments
Describe the issue
Using the experimental resolver nl.littlerobots.vcu.resolver, appears to not utilize the rejectVersionIf from the dependencyUpdates plugin configuration. I have created a sample project where a rejectVersionIf statement is created, but not utilized by the command versionCatalogUpdate.
Steps to reproduce
With the sample project running ./gradlew clean versionCatalogUpdate --interactive
a libs.versions.updates.toml is created with the dependency commons-io version of 20030203.000550. This version is provided because of incorrect metadata in the repository https://repo.grails.org/core, see settings.gradle in the sample project. The expected behavior was that the rejectVersionIf statement would be utilized and the version 20030203.000550 would not be chosen.
Can you provide guidance on how to utilize a reject version strategy against a catalog library entry?
From your sample project, you are configuring rejectVersionIf
on the dependencyUpdates
task. However, that task is not used at all when you switch to the new resolver. You should use a version selection block in stead and compare/filter the versions there:
versionSelector {
// return true to select the passed in candidate
!isNonStable(it.candidate.version)
}
}```
As an aside, it might just be better to setup a strict rule in your version catalog itself als an alternative.
By the way, thanks for providing a sample project, it really helps me to understand and repro the issue ❤️
Appreciate the quick reply! Glad to see the plugin is now able to do resolution without the version plugin. One less dependency.
Using the versionSelector
from within the versionCatalogUpdate
, and am still unable to omit the version 20030203.000550 with task versionCatalogUpdate
from the generated catalog. Here is the versionSelector used
versionSelector {
it.candidate.version != "20030203.000550"
}
Also updated the sample project accordingly. Any thoughts as to what is wrong here?
It looks like the selector is not set correctly or too late when Gradle is running. Debugging it looks like the plugin is configured first, and then the version selector method call is processed. By that time the plugin is already configured with a default version selector.
You can set it directly on the task too as a workaround, but I'd prefer to get the method on the extension working if possible.
tasks.named("versionCatalogUpdate").configure {
versionSelector {
it.candidate.version != "20030203.000550"
}
}
There might also be a difference between .gradle
and .kts
or Gradle versions, I'd have to investigate further to know for sure.