Dynamically access the contents of a catalog

I’m in the process of looking at catalogs for handling common dependencies when migrating from an old version of gradle to 7.x.
I’ve managed to get the catalogs loaded from my toml file, and I can use the type-safe syntax to load my dependencies just fine.
Assuming that I have a ‘libs’ catalog defined in my project, I’d like some way to loop over the contents of the catalog, listing the libraries and bundles contained in the catalog. Ideally I’d like to something like this (although this doesn’t come close to working):

libs.libraries.each { println ("${it.module} = ${it.version}") }

I’ve tried a bunch of stuff, but haven’t been able to figure out how to get a list of libraries or bundles from the libs catalog. Is this possible or am I completely off base?

The libs extension does not have the possibility to enumerate the entries.
But you can use the versionCatalogs extension that provides that capability.
versionCatalogs.named("libs") and then go on from there.

1 Like

Ok, that got me where I need to be. Thanks for the help

1 Like