Slackbot
06/20/2023, 11:34 PMJavi
06/20/2023, 11:34 PMtarget.afterEvaluate {
val implementationDependencies =
target.configurations["implementation"]
.allDependencies
.filterIsInstance<DefaultProjectDependency>()
.toSet()
target.dependencies {
for (dep in implementationDependencies) {
"contextual"(target.project(dep.dependencyProject.path))
}
}
}Javi
06/20/2023, 11:34 PMafterEvaluateJavi
06/20/2023, 11:35 PMChris Lee
06/20/2023, 11:43 PMJavi
06/21/2023, 8:55 AM- Incompatible because this component declares a component, packaged as a jar and the consumer needed a component, with the library elements 'contextual'Javi
06/21/2023, 8:58 AMcontextual part, so it looks like this issue is "similar" to an android library which has two variants and other which has three and it doens't know what to pick, and you need fallbacks and so on.
cc @Thomas BroyerJavi
06/21/2023, 9:11 AMJavi
06/21/2023, 9:51 AMcontextual is extending implementation, and one of the dependencies added to implementation doesn't know anything about contextual which is normal, because that dependency hasn't be processed by my plugin, but, that means that dependency has not added any artifact to the contextual as there is no contextual, so it must be skipped.
How can I mark this attribute as optional?Vampire
06/21/2023, 10:06 AMVampire
06/21/2023, 10:06 AMVampire
06/21/2023, 10:06 AMVampire
06/21/2023, 10:07 AMwhatever if contextual was requested, but then you get the whatever jar.Vampire
06/21/2023, 10:07 AMcontextual is not present, use a lenient artifact view.Adam
06/21/2023, 10:08 AMval contextual by configurations.creating { ... }
contextual.incoming.artifactView {
withVariantReselection()
//lenient(true) // you can also try ignoring failures
}.files
sometimes I found that ‘resolved artifacts’ was necessary - something to do with triggering transforming files
val contextual by configurations.creating { ... }
val contextualContents: Provider<List<File>> = contextual.incoming
.artifactView {
//lenient(true) // you can also try ignoring failures
withVariantReselection()
}.artifacts
.resolvedArtifacts
.map { artifacts ->
artifacts.map { it.file }
}Javi
06/21/2023, 10:14 AMlenient is what I was calling "optional" attribute, thank you both, I will try 🙂Javi
06/21/2023, 10:34 AMlenient(true) works, if I only use withVariantReselection() it doesn't work.Javi
06/21/2023, 10:34 AMVampire
06/21/2023, 10:56 AMif I only useOf course not, why should it? That method means "ignore the attributes declared on the configuration and just resolve again with only the artifact view defined attributes". That doesn't change that your dependency has no matching variant.it doesn't workwithVariantReselection()
Javi
06/21/2023, 11:05 AMVampire
06/21/2023, 12:07 PM