This message was deleted.
# community-support
s
This message was deleted.
a
Have you tried the examples here, with
ResolvedComponentResult
, instead of
ResolvedArtifactResult
? https://docs.gradle.org/current/userguide/incremental_build.html#sec:task_input_using_dependency_resolution_results
t
No, because I already have working solution with
Copy code
variant.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 some
ResolvedArtifactResult
instances, you should instead use
ArtifactCollection.getResolvedArtifacts()
that returns a
Provider<Set<ResolvedArtifactResult>>
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.
I'm currently not sure if it is possible to get
ResolvedComponentResult
from
variant.runtimeConfiguration
which is
org.gradle.api.artifacts.Configuration
class.
a
hmm, it’s possible that not all of the docs are using best-practice for configuration cache could you try the other example, but use
variant.runtimeConfiguration
instead of
configurations.getByName("runtimeClasspath")
, like this?
Copy code
variant.runtimeConfiguration.incoming.artifacts.getResolvedArtifacts();
t
I will try. But it is directly doc about configuration cache https://docs.gradle.org/current/userguide/configuration_cache.html#config_cache:requirements) So I would expected that this will be the source of true 😉
a
it would be nice if it was up to date 😄
t
It looks that
Copy code
@get:Input
abstract val resolvedArtifacts: Property<ResolvedComponentResult>
with
Copy code
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
Copy code
variant.runtimeConfiguration.incoming.artifactView {
   attributes {
      attribute(Attribute.of("artifactType", String::class.java), artifactType)
   }
   isLenient = false
}.artifacts.forEach { .... }
👍 1
I'm always curious why there are exist to many too similar stuf like
ResolvedComponentResult
and
ResolvedArtifactResult
a
t
😞
TL;DR
ResolvedArtifactResult
contains both metadata and files so it cannot be used as a task input directly, you have to extract the data you need from it
t
I need to get list of all dependnecies, including all transitive dependencies and get group, module, version, artifactType and classifier from all of them. So far I did not found a way how to do it with
Copy code
ResolvedComponentResult
So group, module and version is OK, but type and classifier still issue 🙂
artifactType is possible this way 🙂
Copy code
dependency.selected.variants.first().attributes.getAttribute(
    Attribute.of(
        "org.gradle.libraryelements",
        String::class.java
    ))?: "",
no, this returning wrong type