Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble using centralized dependency versions in buildSrc plugins and buildscript classpath #16652

Closed
henrik242 opened this issue Mar 26, 2021 · 1 comment
Labels
a:investigation Issues requiring decision or investigation affects-version:7.0

Comments

@henrik242
Copy link
Contributor

The new centralized dependency versions feature preview in Gradle 7 is pretty great, but there are a couple of places where libs doesn't resolve.

  1. In plugins in buildSrc, e.g. buildSrc/src/main/kotlin/MyPlugin.kt:

    class MyPlugin : Plugin<Project> {
    
        override fun apply(project: Project): Unit = project.run {
    
            dependencies {
                implementation(libs.groovy)
                testImplementation(libs.junit)
                [...]
            }
            [...]
        }
    }
    

    The error I get ise: .../buildSrc/src/main/kotlin/MyPlugin.kt: (21, 32): Unresolved reference: libs

  2. In dependencies/classpath in the root build.gradle.kts:

    buildscript {
        [...]
        dependencies {
            classpath(libs.gradleVersionsPlugin)
            [...]
        }
    }
    

    Error is Script compilation error: Line 27: classpath(libs.gradleVersionsPlugin) Unresolved reference: libs

  3. In the root settings.gradle.kts:

    plugins {
        id("com.gradle.enterprise").version(libs.versions.gradleEnterprise.get())
    }
    

    Throws approximately the same error as in pt. 2.

  4. In the plugins block in buildSrc/build.gradle.kts:

    plugins {
        id("org.jmailen.kotlinter").version(libs.versions.kotlinter.get())
    }
    

    Throws approximately the same error as in pt. 2.

Is there a way to solve any of these?

SEO: enableFeaturePreview("VERSION_CATALOGS")

@melix
Copy link
Contributor

melix commented Mar 29, 2021

There are multiple issues here, it's better to create separate issues for each. However I don't think there's an immediate action to be taken. A follow-up for plugins (4) will be implemented. Please refer to my explanation on the forums: https://discuss.gradle.org/t/trouble-using-centralized-dependency-versions-in-buildsrc-plugins-and-buildscript-classpath/39421/2?u=cedricchampeau

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:investigation Issues requiring decision or investigation affects-version:7.0
Projects
None yet
Development

No branches or pull requests

2 participants