How to convert dependency url to a file name?

Given a dependency declaration like this:

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:


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

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.

Hi Peter,

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

Try something like ‘{ == “commons-beanutils” && == “commons-beanutils” && it.version.startsWith(“1.9”) } as Spec’.

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