You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Configuration secondary variants inherit the primary's attributes. This behaviour is unexplained and undocumented.
Expected Behaviour
Either:
The behaviour is a bug, and Configuration secondary variants should not inherit attributes.
The behaviour is intentional, and should be documented.
(Note: It would be much appreciated if the current behaviour should not just be written down, but also explained to give context. For example, by answering these questions: Why should attributes be automatically inherited? Why would this be advantageous? In what situations is this relevant? Apparently, the inherited attributes can be overridden - when should this be done, if at all?)
I reported this previously #28811, but it was incorrectly closed by @ov7a as a duplicate of an unrelated issue.
Steps to Reproduce
// build.gradle.kts
group ="x.y.z"
version ="1.2.3"val myFooAttribute =Attribute.of("FooAttribute", String::class.java)
val myFooVariantAttribute =Attribute.of("FooVariantAttribute", String::class.java)
val fooFiles:Configuration by configurations.creating {
isCanBeDeclared =false
isCanBeResolved =false
isCanBeConsumed =true
attributes {
attribute(myFooAttribute, "main")
}
}
val fooFilesVariant1:ConfigurationVariant by fooFiles.outgoing.variants.creating {
attributes {
attribute(myFooVariantAttribute, "variant1")
}
}
val fooFilesVariant2:ConfigurationVariant by fooFiles.outgoing.variants.creating {
attributes {
attribute(myFooAttribute, "secondary")
attribute(myFooVariantAttribute, "variant2")
}
}
Run gradle outgoingVariants -q
--------------------------------------------------
Variant fooFiles
--------------------------------------------------
Capabilities
- x.y.z:proj:1.2.3 (default capability)
Attributes
- FooAttribute = main
Secondary Variants (*)
--------------------------------------------------
Secondary Variant fooFilesVariant1
--------------------------------------------------
Attributes
- FooAttribute = main
- FooVariantAttribute = variant1
--------------------------------------------------
Secondary Variant fooFilesVariant2
--------------------------------------------------
Attributes
- FooAttribute = secondary
- FooVariantAttribute = variant2
(*) Secondary variants are variants created via the Configuration#getOutgoing(): ConfigurationPublications API which also participate in selection, in addition to the configuration itself.
Observations:
fooFiles only has FooAttribute = main, which is expected.
fooFilesVariant1 contains FooAttribute = main. This is unexpected behaviour, because it's not documented.
fooFilesVariant2 overrides FooAttribute to be FooAttribute = secondary. Because of the automatic inheritance, I'm now confused. Is overriding the primary's attributes supposed to be allowed? Is it problematic?
Gradle version
8.7
Build scan URL (optional)
No response
Your Environment (optional)
No response
Context (optional)
No response
Page with the problem
n/a
The text was updated successfully, but these errors were encountered:
If you think our analysis is wrong, please provide us with more detailed information explaining why.
Sorry, I don't see this as a constructive behavior. You can dislike our decisions, but spamming like this is a waste of everybody's time.
Regarding the issue - the title of the supposedly unrelated issue is "Please improve variant/attribute documentation / error messages", and your issue is related to secondary variants. They are clearly related.
A kind reminder that this repository is a subject of CoC.
Issue type
Wrong or misleading information
Problem description
Current Behaviour
Configuration secondary variants inherit the primary's attributes. This behaviour is unexplained and undocumented.
Expected Behaviour
Either:
The behaviour is a bug, and Configuration secondary variants should not inherit attributes.
The behaviour is intentional, and should be documented.
(Note: It would be much appreciated if the current behaviour should not just be written down, but also explained to give context. For example, by answering these questions: Why should attributes be automatically inherited? Why would this be advantageous? In what situations is this relevant? Apparently, the inherited attributes can be overridden - when should this be done, if at all?)
Context
Related: #28149
I reported this previously #28811, but it was incorrectly closed by @ov7a as a duplicate of an unrelated issue.
Steps to Reproduce
Run
gradle outgoingVariants -q
Observations:
fooFiles
only hasFooAttribute = main
, which is expected.fooFilesVariant1
containsFooAttribute = main
. This is unexpected behaviour, because it's not documented.fooFilesVariant2
overridesFooAttribute
to beFooAttribute = secondary
. Because of the automatic inheritance, I'm now confused. Is overriding the primary's attributes supposed to be allowed? Is it problematic?Gradle version
8.7
Build scan URL (optional)
No response
Your Environment (optional)
No response
Context (optional)
No response
Page with the problem
n/a
The text was updated successfully, but these errors were encountered: