Get installed artifacts/jars from dependencies

In a custom plugin I iterate the dependencies for a sourceSet that I have explicitly created for some of my projects:

project.configurations.each { conf ->
      def configurationName = conf.name
      if(configurationName.equals("mysourceSetCompile")) {
         conf.allDependencies.each { dep ->
          println "
    ${dep.group}:${dep.name}:${dep.version}"
          //String relativePathToArtifact = computePathToArtifact(dep)
        }
      }
    }

I need to manually access the corresponding jars/artifact which are currently stored/installed to the local .m2 repo (using the gradle maven plugin). Any suggestions for a good approach to get these artifacts?

I am currently hacking my way through this by combining the dependency coordinates and the location of the m2 repo to create a valid filePath.

The Gradle maven plugin doesn’t copy all dependencies to the maven local repository, so it’s not guaranteed that all of your dependencies will be there (unless you can guarantee this because you are doing this yourself somehow).

Do you just need to get a hold of the file object? Or is it more than that?

Yes a pointer to the file object could be nice. It is only my own project dependencies that I am iterating which as I understand are always installed into the m2 repo:

http://www.gradle.org/docs/current/userguide/maven_plugin.html

which as I understand are always installed into the m2 repo

This doesn’t happen automatically, only when you manually run ‘install’.

You need to look at Configuration.resolvedConfiguration to get the file handles.