Copy immediate sub project external jar

(trisport88) #1

When I list the runtime dependencies of a particular sub project (e.g. project2) I see something list this:

±-- project :project1
| ±-- :other_jar(s)
— org.apache.commons:commons-math3:3.3

For each subproject I need to copy the external jars into a particular directory and what I currently do is this:

    configurations.runtime.getFiles().each {File jarFile ->
        if (jarFile.getPath().contains("${File.separator}.gradle${File.separator}"))
            copy {
                into file(“/someLocation”)
                from jarFile

The trouble is that for project2 it ends up copying the external jars for project1 also. Even though project2 is dependent on project1 I only want to copy the external jars that project2 is immediately dependent on (so not ones that it is dependent on because of another project).

Any help would be much appreciated.



(trisport88) #2

Is there a way to access the logic that builds the dependencies tree? If I could do that I could just grab the first level of the tree.

gradle project2:dependencies --configuration runtime