Kotlin / kotlinx-kover

Apache License 2.0
1.37k stars 53 forks source link

Gradle Plugin: Configurations should add Gradle.USAGE attribute to eg kover #678

Closed hfhbd closed 2 months ago

hfhbd commented 2 months ago

Describe the bug All outgoing configurations of Kover don't set the Gradle.USAGE attribute. Without this attribute, Gradles attribute matching algorithm accepts kovers artifacts even if you (as Gradle plugin author) want to resolve artifacts with other attributes.

Use-case: I applied the kover plugin using the settings plugin and have a custom Gradle plugin that wants to resolve a configuration with USAGE but there is no configuration with matching USAGE so Gradle should fail. But Gradles attribute matching algorithm (wrongly) choose a consumable configuration as long as there are no conflicting attributes, and ignores requires/provided attributes. So without USAGE attribute, Gradle simply choose kover artifacts. The Gradle USAGE attribute is the most relevant attribute (Indicates main purpose of variant) and Gradle authors should set it.

Errors n/a

Expected behavior A Gradle variant error because I fetch Gradle.USAGE="foo" and kover provides Gradle.USAGE="kover"

Reproducer n/a

Reports n/a

Environment

shanshin commented 2 months ago

Thanks for the hint! Indeed, it is better to specify this attribute

shanshin commented 2 months ago

Implemented in 0.9.0-RC