Version catalog access from plugin

I’ve implemented a versions catalog in my system, really loving this new api. I’m wondering if it is possible to access the version catalog from inside a plugin? I’d like to detect if a catalog exists, apply some entries to various configurations.

Use the version of libs.version.toml in buildSrc?

Yeah, that’s what I’m asking, I’ve built a plugin implementing org.gradle.api.Plugin<org.gradle.api.Project>. I can’t seem to find a way to access catalog from the project api, and I was curious if I missed something, or if there is an alternative approach to get data from the catalog into my plugin.

it’s not difficult
You should add this code in settings.gradle in buildSrc

dependencyResolutionManagement {
    versionCatalogs {
        libs {
            from(files("../gradle/libs.versions.toml"))
        }
    }
}

Here is my usage example

def springbootVersion = project.rootProject
                .extensions
                .getByType(VersionCatalogsExtension.class)
                .named("libs")
                .findVersion("springBoot")
                .get()
                .displayName

If you still don’t understand, you can refer to my github
my github
Good luck

This is exactly what I was looking for! Thanks!!!