Hi <@U19Q5CC4S>, i saw that you implemented this f...
# gradle
i
Hi @melix, i saw that you implemented this feature https://github.com/gradle/gradle/issues/15382 And that it’s merged. But i don’t understand how to use it, currently I’m working on a binary conventions plugin for my team. I created a version catalog in another plugin using the gradle version-catalog plugin, and i’m consuming it in the conventions plugin settings.gradle.kts like so:
Copy code
enableFeaturePreview("VERSION_CATALOGS")
dependencyResolutionManagement {
    versionCatalogs {
        create("libs") {
            from("<http://com.me:me-version-catalog:0.0.1-SNAPSHOT|com.me:me-version-catalog:0.0.1-SNAPSHOT>")
        }
    }
}
Now i want to access it in my binary plugin code but i don’t have access to libs.something Can you give any advice? or perhaps add a use example in the PR? Thanks
j
you need to use the unsafe api as the issue shows
i
@Javier I tried that, but I’m getting an error when applying the plug-in, saying the version catalog extension was not found Can you provide a use example? The code snippet in the original issue ticket is not sufficient
j
Copy code
the<VersionCatalogsExtension>()
That is working for me, not sure which Gradle version are you using
i
I got it now, thanks
for anyone interested:
Copy code
abstract class Conventions : Plugin<Project> {
    protected var versionCatalog by Delegates.notNull<VersionCatalog>()

    override fun apply(target: Project) {
        with(target) {
            versionCatalog = the<VersionCatalogsExtension>().find("versionCatalog").get()

...

    private fun Project.configureJavaPlugin() {
        extensions.configure(JavaPluginExtension::class.java) {
            val java = versionCatalog.findVersion("java").get().displayName