littlerobots / version-catalog-update-plugin

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

Configuration for additional version catalog unexpectedly applies to default version catalog #147

Open marloustolk opened 5 months ago

marloustolk commented 5 months ago

Some of the libraries I use are being deleted on update (they get flagged as unused). If I use @keep they will not get updates anymore and if I use the configuration keepUnusedLibraries.set(true) any possible unused library will not be deleted anymore. That is why I wrote an additional version catalog containing the libraries I want to keep that get deleted on updates. Then I used a different configuration for this catalog.

versionCatalogUpdate {
    keep {
        keepUnusedLibraries.set(false)
    }
    versionCatalogs {
        create("keeplibs") {
            catalogFile.set(file("gradle/keeplibs.versions.toml"))
            keep {
                 keepUnusedLibraries.set(true)
            }
        }
    }
}

I expected that the libraries in libs.versions.toml still get deleted when unused and the libraries in keeplibs.versions.toml never get deleted. This configuration unexpectedly results in that all libraries (in both catalogs) never get deleted.

gradle 8.5 version-catalog-update 0.8.4

hvisser commented 5 months ago

The dependency update plugin will only find updates if you have the dependencies actually referenced in your app. If they don't appear in your dependencies at all, then they will be considered unused. If you decide to mark those as "keep" they will always be retained, but never upgraded because the dependencies are never discovered/used.

You can also enable the new resolver (see #125 for details). This doesn't use the dependency versions plugin anymore but uses the catalog for the version information. For 1.0 this will be the default, but since it's quite a big change it's still behind a flag.