How to retrieve a list of actual dependencies (including transitive deps)

project.configurations.compile.each { println it.name }

prints nicely all dependencies - and importantly all transitive deps as well -. Only the objects in the closure are of type File

I want to some similar but get an hold on all dependencies as Depedency object as well.

What I would like to do is to retrieve all dependencies (including transitive deps). Then I want 1) have an easy API to get the name of the dep (e.g. without version) 2) have access to the file handler itself

I have been looking at the http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.Configuration.html and all of it’s methods but can seem to find what I need…

Thanks in advance, Marcel

Just for full reference: I want to unpack the found dependencies to a local folder which name will be the dependency without the version.

So 1) I can take the filename of the archive and remove version stuff or 2) Use an API to retrieve what I need (which I prefer)

It sounds like you want the [ResolvedConfiguration] (http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.Configuration.html#org.gradle.api.artifacts.Configuration:resolvedConfiguration)

@mattkhan

I don’t see how I can get what I want from ResolvedConfiguration as you mentioned. That class only provides api to get direct dependencies (via getFirstLevelModuleDependencies()) and not transitive dependencies.

Yes, this did the trick:

project.configurations.compile.resolvedConfiguration.resolvedArtifacts.each {
 println it.name // << the artifact name
 println it.file // << the file reference
}

Thanks for your help!