I know this answer comes a bit late, but still...
The transitive param you wrote is going to include transitive dependencies (dependencies of your dependency), which have to be set in the pom.xml file of the dependency you set to compile. So you don't really need to do that for the aar packaging, unless it's intended for any other purpose.
First, think that you can package an aar with some jars inside (in the
libs folder), but you cannot package an aar inside an aar.
The approach to solve your problem is:
- Get the resolved artifacts from the dependency you are interested in.
- Check which ones of the resolved artifacts are
jar files.
- If they are
jar, copy them to a folder and set to compile that folder in your dependencies closure.
So more or less something like this:
configurations {
mypackage // create a new configuration, whose dependencies will be inspected
}
dependencies {
mypackage 'com.zendesk:sdk:1.7.0.1' // set your dependency referenced by the mypackage configuration
compile fileTree(dir: "${buildDir.path}/resolvedArtifacts", include: ['*.jar']) // this will compile the jar files within that folder, although the files are not there yet
}
task resolveArtifacts(type: Copy) {
// iterate over the resolved artifacts from your 'mypackage' configuration
configurations.mypackage.resolvedConfiguration.resolvedArtifacts.each { ResolvedArtifact resolvedArtifact ->
// check if the resolved artifact is a jar file
if ((resolvedArtifact.file.name.drop(resolvedArtifact.file.name.lastIndexOf('.') + 1) == 'jar')) {
// in case it is, copy it to the folder that is set to 'compile' in your 'dependencies' closure
from resolvedArtifact.file
into "${buildDir.path}/resolvedArtifacts"
}
}
}
Now you can run ./gradlew clean resolveArtifacts build and the aar package will have the resolved jars inside.
I hope this helps.