Not able to use plugin from version catelog

Hello,

I am currenty using convention plugin. In my convention.gradle.kts I am using one plugin

plugins {
    application
    jacoco
    id("nu.studer.credentials")
}

My build.gradle.kts unde buildSrc is as follows:

plugins {
    `kotlin-dsl`
    id("com.github.ben-manes.versions") version "0.36.0"
}

dependencies{
    implementation("nu.studer:gradle-credentials-plugin:3.0")
}

I am trying to add version catelog to remove hardcoded version from dependency section here. I added a libs.versions.toml file in gradle folder

[plugins]
nu-studer-credentials = { id = "nu.studer.credentials", version = "3.0" }

setting.gradle.kts in buildSrc folder:

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

Now while refractoring build.gradle.kts (under buildSrc) I am getting error on “libs” as unrecorgnized reference.

plugins {
    `kotlin-dsl`
    id("com.github.ben-manes.versions") version "0.36.0"
    alias(libs.nu.studer.credentials)
}

dependencies{
    implementation(libs.plugins.nu.studer.credentials)
}

Could someone please point me to right direction here.

Regards,

Why do you now apply the plugin to buildSrc/build.gradle.kts? You did not do that before.

You cannot use libs.plugins... as is in dependencies { ... } yet, see Accept plugin declarations from version catalog also as libraries · Issue #17963 · gradle/gradle · GitHub for more information and also work-arounds how to still do it.

Both of this should not result in “libs” as unrecognized though. Do you get that from Gradle or from IDE? If the latter, resync the project. If the former, please provide exact error, optimally through a build --scan URL.