How to convert dependency url to a file name?


(Carlo Luib-Finetti) #1

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:

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

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


(Peter Niederwieser) #2

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.


(Carlo Luib-Finetti) #3

Hi Peter,

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


(Peter Niederwieser) #4

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


(Carlo Luib-Finetti) #5

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