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

Gradle is not honoring status attribute for buildscript classpath dependencies when using plugin markers #28933

Open
rpalcolea opened this issue Apr 23, 2024 · 1 comment · May be fixed by #28981
Labels
a:regression This used to work affects-version:8.7 in:dependency-declarations variant notation attributes capability substitution

Comments

@rpalcolea
Copy link
Contributor

rpalcolea commented Apr 23, 2024

Current Behavior

When setting org.gradle.status for buildscript classpath dependencies via AttributeContainer, it results in a deprecation and not honoring this opinion.

Expected Behavior

Setting org.gradle.status attribute for buildscript classpath dependencies should be honored and not result in a deprecation when using plugin marker dependencies

Context (optional)

No response

Steps to Reproduce

Given the following build file:

buildscript {
    configurations.all { configuration ->
        configuration.withDependencies { dependencies ->
            dependencies.each { ModuleDependency dependency ->
                dependency.attributes({ AttributeContainer attributeContainer ->
                    attributeContainer.attribute(Attribute.of("org.gradle.status", String.class), "release")
                })
            }
        }
    }
}

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.9.22'
}

When running ./gradlew bE (or any task), you will see the following:

> Configure project :
Cannot set attributes for dependency "org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.9.22": it was probably created by a plugin using internal APIs

This only happens in 8.7

Similarly, if you have something like

buildscript {
    configurations.all { configuration ->
        configuration.withDependencies { dependencies ->
            dependencies.each { ModuleDependency dependency ->
                dependency.attributes({ AttributeContainer attributeContainer ->
                    attributeContainer.attribute(Attribute.of("org.gradle.status", String.class), "snapshot")
                })
            }
        }
    }
}

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.+'
}

The status attribute is used correctly in 8.6 but in 8.7 it results in picking up a version

8.6 output

* What went wrong:
A problem occurred configuring root project 'status-issue'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find any version that matches org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.+.
     Versions that do not match:
       - 2.0.0-RC1
       - 2.0.0-Beta5
       - 2.0.0-Beta4
       - 2.0.0-Beta3
       - 2.0.0-Beta2
       - + 6 more
     Versions rejected by attribute matching:
       - 1.9.23:
           - Attribute 'org.gradle.category' didn't match. Requested 'library', was: not found
           - Attribute 'org.gradle.dependency.bundling' didn't match. Requested 'external', was: not found
           - Attribute 'org.gradle.jvm.version' didn't match. Requested '21', was: not found
           - Attribute 'org.gradle.libraryelements' didn't match. Requested 'jar', was: not found
           - Attribute 'org.gradle.plugin.api-version' didn't match. Requested '8.6', was: not found
           - Attribute 'org.gradle.status' didn't match. Requested 'snapshot', was: 'release'
           - Attribute 'org.gradle.usage' didn't match. Requested 'java-runtime', was: not found
         

8.7 output

classpath
\--- org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.+ -> 1.9.23
     \--- org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23

It appears some work has to happen in

private ModuleDependency getMarkerDependency(PluginRequestInternal pluginRequest) {

Gradle version

8.7

Build scan URL (optional)

https://scans.gradle.com/s/4qb632y4mq6jc

Your Environment (optional)

Operating system macOS 14.4 (aarch64)
CPU cores 16 cores
Max Gradle workers 16 workers
Java runtime Azul Zulu OpenJDK Runtime Environment 21.0.2+13-LTS
Java VM Azul Zulu OpenJDK 64-Bit Server VM 21.0.2+13-LTS (mixed mode, sharing)

@ov7a ov7a added the in:dependency-declarations variant notation attributes capability substitution label Apr 25, 2024
@ov7a
Copy link
Member

ov7a commented Apr 25, 2024

The issue is in the backlog of the relevant team and is prioritized by them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:regression This used to work affects-version:8.7 in:dependency-declarations variant notation attributes capability substitution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants