Gradle maven dependency


(Thomas Lee) #1

I have two dependencies where they further have dependencies on the maven and thus download itself. I saw the log shows the extra files are downloaded. But it is not able to show and unzip the extra dependencies that on Maven.

project.configurations.compile.allDependencies.each{ dep->

//for each dependency to find the related file

File zipFile = project.configurations.compile.findAll {

it.path.contains(dep.name) && it.path.contains(’.zip’);

}.collect { it.path };

ant.unzip(src: zipFile, dest: dest + “/” + dep.group + “.” + dep.name);

logger.debug("Unzip the file from the group {} , dependency {} ",dep.group, dep.name);

}

e.g

dependencies {

compile group: “com.abc”, name: “basic”,version: “2.0.2”

compile group: “com.abc”, name: “normal”, version: “2.0.2”

}

It can unzip the above two files. But in fact “basic” will mention further artifact “basic1” as dependencies in the pom.xml

Do you know any api that can also scan through all the dep including those further dependency from the maven? or any way to specific what to do after downloaded ?

I have a workaround to extract the file by “project.configurations.compile.getFiles()” but it is rather hard code…


(Peter Niederwieser) #2

Try ‘configuration.resolvedConfiguration.resolvedArtifacts’.