Slackbot
04/08/2022, 8:26 AMVampire
04/08/2022, 9:01 AMjava-library
for example I only have
⢠apiElements
⢠mainSourceElements (i)
⢠runtimeElements
⢠testResultsElementsForTest (i)Tapchicoma
04/08/2022, 9:02 AMoutgoingVariants --variant default
?Louis Jacomet
04/08/2022, 9:12 AMdefault
has no attributes set by the Java plugins normally.
It should be considered a legacy configuration and no plugins should add attributes to it.
I suspect that the Kotlin plugin ends up adding attributes to it as I remember it doing that for all consumable configurations.Tapchicoma
04/08/2022, 9:15 AMCould not determine the dependencies of task ':kotlin-gradle-plugin-idea:test'.
> Could not resolve all task dependencies for configuration ':kotlin-gradle-plugin-idea:testRuntimeClasspath'.
> Could not resolve project :kotlin-gradle-plugin.
Required by:
project :kotlin-gradle-plugin-idea
> The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'. However we cannot choose between the following variants of project :kotlin-gradle-plugin:
- default
- gradle70RuntimeElements
- runtimeElements
All of them match the consumer attributes:
- Variant 'default' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.255-SNAPSHOT declares a component, preferably optimized for standard JVMs, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Unmatched attributes:
- Doesn't say anything about its component category (required a library)
- Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about its usage (required a runtime)
- Variant 'gradle70RuntimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.255-SNAPSHOT declares a runtime of a library compatible with Java 8, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Unmatched attribute:
- Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
- Variant 'runtimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.255-SNAPSHOT declares a runtime of a library compatible with Java 8, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
Seems default
and runtimeElements
has same capability and then Gradle fails to select oneTapchicoma
04/08/2022, 9:16 AMVampire
04/08/2022, 9:17 AM--all
, I also see default
and archives
legacy ones, just never had a problem with them.Vampire
04/08/2022, 9:18 AMoutgoingVariants --all
say for you?Tapchicoma
04/08/2022, 9:20 AMI think it automatically selects the one with the most matching attributes
runtimeElements
has the most matching attributes, though default
has 5 without any valueVampire
04/08/2022, 9:21 AMTapchicoma
04/08/2022, 9:21 AMWhat doeshttps://ge.jetbrains.com/s/u2y5ykm5ynhkk/console-logsay for you?outgoingVariants --all
Tapchicoma
04/08/2022, 9:30 AMI suspect that the Kotlin plugin ends up adding attributes to it as I remember it doing that for all consumable configurations.You are right - there are 2 attributes seems added by KGP. I will open an issue for this. Is there a way to detect such legacy configurations?
Vampire
04/08/2022, 9:31 AMdefault
has no attributes at all, in your case it has org.gradle.jvm.environment
and org.jetbrains.kotlin.platform.type
.
So I guess the Kotlin plugin should be fixed and as a work-around on the producer side, you remove the attributes the plugin added.
Or as a consumer-side work-around you can use a component metadata rule to remove the attributes.Vampire
04/08/2022, 9:35 AMIs there a way to detect such legacy configurationsMy first guess would be, if they are resolvable and consumable
Vampire
04/08/2022, 9:37 AM(l) Legacy or deprecated configuration. Those are variants created for backwards compatibility which are both resolvable and consumable.
Vampire
04/08/2022, 9:37 AMoutgoingVariants
Tapchicoma
04/08/2022, 9:37 AMOr as a consumer-side work-around you can use a component metadata rule to remove the attributes.Do you have such example nearby? I am looking into
ComponentMetadataRule
and seems it only possible either modify existing or add new one attributeTapchicoma
04/08/2022, 9:42 AMVampire
04/08/2022, 9:45 AMMy first guess would be, if they are resolvable and consumableYes, I was right:
if (configuration.isCanBeConsumed() && configuration.isCanBeResolved()) {
type = ReportConfiguration.Type.LEGACY;
}
Louis Jacomet
04/08/2022, 9:46 AMVampire
04/08/2022, 9:48 AMDo you have such example nearby? I am looking intotbh, I never tried, I just assumed it works. But even if you just can modify existing ones and add new ones, then modify one of the two to an incompatible value and it should hopefully workand seems it only possible either modify existing or add new one attributeComponentMetadataRule
Louis Jacomet
04/08/2022, 9:53 AMVampire
04/08/2022, 9:57 AMTapchicoma
04/08/2022, 10:22 AMthen modify one of the two to an incompatible value and it should hopefully workI've changed one of attribute values in
default
variant and that solved the issue ā
Thank you for discussion š