How to copy resolved runtime dependencies of subprojects which are defined in bulid.gradle?

Hallo, we have developed a gradle plugin which iterates over (all) subpojrects and this pluign should copy their runtime dependencies into a directory. Problem is the runtime dependencies which I try to copy are not resolved when I copy them. I only can copy the unresolved runtime dependencies. The runitme dependencies are defined inside the gradle build srcript. That is the code of the plugin I developed for getting and copying the runtime dependencies:

void buildAmp (subproject)
{
  // assemble amp in subdir
  String ampDir = subproject.buildDir.path + '/amp'
  project.ant.mkdir(dir: ampDir)
    // copy dependent JARs to /lib
  subproject.configurations.runtime.copy().files.findAll { dep -> dep.name.endsWith '.jar' }.each { jarFile ->
   project.ant.copy(file: jarFile.path, toDir: ampDir + '/lib', overwrite: true)
  }
}

Problem is that “.runtime.copy()” copying the non resolved dependencies.

How is it able to get the resolved dependencies for the runtime dependencies of the subproject ? And not the unresolved?

I have founded a way, but this is not that what we need, because it returns too much dependencies:

subproject.configurations.runtime.resolve().findAll { dep -> dep.name.endsWith '.jar' }.each { jarFile ->
   project.ant.copy(file: jarFile.path, toDir: ampDir + '/lib', overwrite: true)
  }

Problem is that “runtime.resolve().” is returning more then 100 MB on jar files( see http://www.gradle.org/docs/current/javadoc/org/gradle/api/artifacts/Configuration.html#copy() ).

Seems that this could be what we need (but do not know how to call this method. Can not get the class/object for calling the get target method-, see http://www.gradle.org/docs/current/javadoc/org/gradle/api/artifacts/DependencyResolveDetails.html) - I use the newest gradle version:

ModuleVersionSelector getTarget()

In the gradle build script the multiple subprojects are defined and the plugin iterates over them. For example a dependency is defined for a jar library in build.gradle. This library has a tree of multiple transitive dependencies. Within this tree one dependency is for ‘commons-lang:commons-lang:2.4’. Alfresco SDK 4.1.5 itself comes with a dependency for commons-lang:commons-lang:2.6. Please note that commons-lang is just an example. This may also occur for any other library.

Gradle is able to handle this conflict pretty well. It chooses version 2.6 for both: …/gradle-1.8/bin/gradle -q “E-Akte Repository”:dependencyInsight --dependency commons-lang --configuration runtime […] commons-lang:commons-lang:2.6 (conflict resolution) — org.alfresco.enterprise-sdk:alfresco:4.1.5

— runtime

commons-lang:commons-lang:2.3 -> 2.6 — net.sf.ezmorph:ezmorph:1.0.6

— net.sf.json-lib:json-lib:2.2.3

— com.westernacher.archive:archive-client:0.1.1-SNAPSHOT

— runtime

commons-lang:commons-lang:2.4 -> 2.6 ±-- commons-configuration:commons-configuration:1.6 | — org.apache.hadoop:hadoop-core:1.0.0 | — org.fusesource.fuse-extra:fusemq-leveldb:1.1 | — org.apache.activemq:activemq-core:5.6.0 | — runtime — net.sf.json-lib:json-lib:2.2.3

— com.westernacher.archive:archive-client:0.1.1-SNAPSHOT

— runtime

When building the the project with the plugin unfortunately the 2.4 version is included instead. It by-passes. Gradles conflict resolution strategy. In my project this results in the issue that I end up with 2 versions of commons-lang in WEB-INF/lib and the classloader pulls the older which causes errors.

I thank you very much when you could just tell me the right copy call and how to get the object for accessing the copy call of the resolved runtime dependency. Thank you very much for your help.

Best regards Amin

By the way: We use following plugins which :

allprojects { // …

apply plugin: ‘java’

apply plugin: ‘war’

apply plugin: ‘maven’ // … }

By the way: We use following plugins which :

allprojects { // … apply plugin: ‘java’ apply plugin: ‘war’ apply plugin: ‘maven’ // … }

Hi,

all I need to know is only to get all transitiv runtime dependencies which are in resolved state. I need to copy them!! Nothing more!