Get installed artifacts/jars from dependencies

(tulsoba) #1

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 =
      if(configurationName.equals("mysourceSetCompile")) {
         conf.allDependencies.each { dep ->
          println "
          //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.

(Luke Daley) #2

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?

(tulsoba) #3

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:

(Luke Daley) #4

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.