# How to convert dependency url to a file name?

**URL:** <https://discuss.gradle.org/t/how-to-convert-dependency-url-to-a-file-name/6305>\
**Category:** Old Forum Archive\
**Created:** [June 3, 2014, 1:20pm UTC](https://discuss.gradle.org/t/how-to-convert-dependency-url-to-a-file-name/6305 "2014-06-03T13:20:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlo\_lf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/carlo_lf/32/1881_2.png) [@carlo\_lf](https://discuss.gradle.org/u/carlo_lf)\
**Post date:** [June 3, 2014, 1:20pm UTC](https://discuss.gradle.org/t/how-to-convert-dependency-url-to-a-file-name/6305/1 "2014-06-03T13:20:00Z")

</div>

Given a dependency declaration like this:

```gradle
ext.libraries = [
   commons_beanutils : 'commons-beanutils:commons-beanutils:1.9.+',
(...)
]

```

is there a way to get the Jar file name of this dependency for use at some other place, where I have to write an Eclipse config.ini like this:

```gradle
/reference\:file\:commons-beanutils-1.9.2.jar/,

```

so that I do not have to hard code the version number here?

---

<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:** [June 3, 2014, 3:19pm UTC](https://discuss.gradle.org/t/how-to-convert-dependency-url-to-a-file-name/6305/2 "2014-06-03T15:19:00Z")

</div>

You’ll need a configuration to resolve the dependency from. Then you should be able to use something like ‘config.resolvedConfiguration.getFiles(“commons-beanutils:commons-beanutils:1.9.+”)’, although I haven’t checked if this also works for dynamic dependencies.

---

<div class="post-metadata">

**Author:** ![carlo\_lf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/carlo_lf/32/1881_2.png) [@carlo\_lf](https://discuss.gradle.org/u/carlo_lf)\
**Post date:** [June 5, 2014, 8:33am UTC](https://discuss.gradle.org/t/how-to-convert-dependency-url-to-a-file-name/6305/3 "2014-06-05T08:33:00Z")

</div>

Hi Peter,

getFiles expects a parameter argument with type “Spec\<? super Dependency\>”. So, how can I get such an object having just a string?

---

<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:** [June 5, 2014, 7:00pm UTC](https://discuss.gradle.org/t/how-to-convert-dependency-url-to-a-file-name/6305/4 "2014-06-05T19:00:00Z")

</div>

Try something like ‘{ it.group == “commons-beanutils” && [it.name](http://it.name) == “commons-beanutils” && it.version.startsWith(“1.9”) } as Spec’.

---

<div class="post-metadata">

**Author:** ![carlo\_lf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/carlo_lf/32/1881_2.png) [@carlo\_lf](https://discuss.gradle.org/u/carlo_lf)\
**Post date:** [June 11, 2014, 9:03am UTC](https://discuss.gradle.org/t/how-to-convert-dependency-url-to-a-file-name/6305/5 "2014-06-11T09:03:00Z")

</div>

Thanks, Peter, this works. The only thing I had to do is to filter out recursive dependencies which are listed as well.
