# How to retrieve the resolvedArtifact without iterating through 'each'

**URL:** <https://discuss.gradle.org/t/how-to-retrieve-the-resolvedartifact-without-iterating-through-each/4836>\
**Category:** Old Forum Archive\
**Created:** [October 4, 2013, 3:38pm UTC](https://discuss.gradle.org/t/how-to-retrieve-the-resolvedartifact-without-iterating-through-each/4836 "2013-10-04T15:38:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjtkirk](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@cjtkirk](https://discuss.gradle.org/u/cjtkirk)\
**Post date:** [October 4, 2013, 3:38pm UTC](https://discuss.gradle.org/t/how-to-retrieve-the-resolvedartifact-without-iterating-through-each/4836/1 "2013-10-04T15:38:00Z")

</div>

I know how to obtain the File object of a resolved dependency by iterating the then examining the name.

And that works fine, but there must a way to obtain the exact dependency I want (by its group: and name: ) WITHOUT looping and “iffing”.

I have struggled with this for a long time and always end up writing the looping code.

I want the full path (/home/foo/.gradle/caches/…) of the dependency

`
configurations.spectrumDependency.resolvedConfiguration.resolvedArtifacts.each { dep ->
logger.info ‘found dependency ------’ + dep.name
if ( dep.name == ‘my-artifact’ ) …
}
 
Any guidance to point me to the right API or examples would be appreciated.
Thanks`

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [October 4, 2013, 5:21pm UTC](https://discuss.gradle.org/t/how-to-retrieve-the-resolvedartifact-without-iterating-through-each/4836/2 "2013-10-04T17:21:00Z")

</div>

You can use the Groovy ‘find’ method:

```gradle
def config = configurations.spectrumDependency.resolvedConfiguration
def artifact = config.resolvedArtifacts.find { it.name == "my-artifact" }

```

---

<div class="post-metadata">

**Author:** ![cjtkirk](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@cjtkirk](https://discuss.gradle.org/u/cjtkirk)\
**Post date:** [October 4, 2013, 9:09pm UTC](https://discuss.gradle.org/t/how-to-retrieve-the-resolvedartifact-without-iterating-through-each/4836/3 "2013-10-04T21:09:00Z")

</div>

Standard groovy stuff. I should have known that.

I realize I need to find how to study the API to see that resolvedArtifacts object had a ‘find’ method (that accepts a Closure).

I assume the API has such info and I just need to dig in a bit more.

Thanks very much
