Could someone provide some examples of using a dependencySpec?


(chriswachter999) #1

I was starting to poke around the new dependency resolution stuff because I think things like:

project.configurations.foo.getResolvedConfiguration().getLenientConfiguration().getFiles(myDependencySpec)

might be useful. However, I’m not sure how to generate useful dependency specs. I found the ‘Specs’ class which looks relevant, particularly its ‘convertClosureToSpec’ method. But I don’t know what I should be doing in my closure.

Could anyone post some examples or descriptions of what a dependencySpec looks like/does?

Thanks in advance, Chris


(Peter Niederwieser) #2

The closure accepts an ‘org.gradle.api.artifacts.Dependency’ and should return true or false depending on whether it wants the dependency’s files included in the result or not. Alternatively, you can implement and pass an ‘org.gradle.api.specs.Spec’ that does the same. The latter is mostly interesting for non-Groovy code.


(chriswachter999) #3

Thank you - that’s what I needed.