How to get the dependencies from a custom plugin

Thank you again.
How do I get all the transitive dependencies? Now I get the dependencies stated in build.gradle from my “compile” configuration, but not the dependencies of those dependencies. I see that this groovy task defined in my build.gradletask

copyDependencies(type: Copy) {
   from configurations.compile
   into 'lib'
}

copies all the transitive dependencies to lib. I need to get them in my custom plugin too.

Thank you very much.