Slackbot
05/04/2023, 9:15 PMAdam
05/04/2023, 9:21 PMResolvedComponentResult
, instead of ResolvedArtifactResult
?
https://docs.gradle.org/current/userguide/incremental_build.html#sec:task_input_using_dependency_resolution_resultsTomáš Procházka
05/04/2023, 9:28 PMvariant.runtimeConfiguration.incoming.artifacts.forEach { ... }
(variant is android stuff)
And since I cannot put variant as task input, i looked for solution and in the doc is this
In the same vein, if you reference someI'm currently not sure if it is possible to getinstances, you should instead useResolvedArtifactResult
that returns aArtifactCollection.getResolvedArtifacts()
that can be mapped as an input to your task. The rule of thumb is that tasks must not reference resolved results, but lazy specifications instead, in order to do the dependency resolution at execution time.Provider<Set<ResolvedArtifactResult>>
ResolvedComponentResult
from variant.runtimeConfiguration
which is org.gradle.api.artifacts.Configuration
class.Adam
05/04/2023, 9:31 PMvariant.runtimeConfiguration
instead of configurations.getByName("runtimeClasspath")
, like this?
variant.runtimeConfiguration.incoming.artifacts.getResolvedArtifacts();
Tomáš Procházka
05/04/2023, 9:33 PMAdam
05/04/2023, 9:34 PMTomáš Procházka
05/04/2023, 9:49 PM@get:Input
abstract val resolvedArtifacts: Property<ResolvedComponentResult>
with
variant.runtimeConfiguration.incoming.resolutionResult.rootComponent
works
At least it no crash. I need to investigate what is inside of ResolvedComponentResult and how to use it.
One thing was not possible to use there.
I was using filter defined like
variant.runtimeConfiguration.incoming.artifactView {
attributes {
attribute(Attribute.of("artifactType", String::class.java), artifactType)
}
isLenient = false
}.artifacts.forEach { .... }
Tomáš Procházka
05/04/2023, 9:51 PMResolvedComponentResult
and ResolvedArtifactResult
Adam
05/04/2023, 9:53 PMTomáš Procházka
05/04/2023, 9:55 PMPaul Merlin
05/05/2023, 5:54 AMPaul Merlin
05/05/2023, 5:54 AMResolvedArtifactResult
contains both metadata and files so it cannot be used as a task input directly, you have to extract the data you need from itTomáš Procházka
05/05/2023, 3:28 PMResolvedComponentResult
Tomáš Procházka
05/05/2023, 3:45 PMTomáš Procházka
05/05/2023, 7:06 PMdependency.selected.variants.first().attributes.getAttribute(
Attribute.of(
"org.gradle.libraryelements",
String::class.java
))?: "",
Tomáš Procházka
05/05/2023, 7:13 PMTomáš Procházka
05/05/2023, 9:36 PM