Task type: Copy documentation

How to understand the following task? Gradle docs tell that Copy used for copying.
Some tutorial tells that the calling the below task causes gradle to download, copy all application and test dependencies while not actually saving them to /tmp. I don’t understand it and what are
configurations.runtime + configurations.testRuntime

 task copyDeps(type: Copy) {
    from (configurations.runtime + configurations.testRuntime) exclude '*'
    into '/tmp'

A Copy task is usually used for copying, but if you exclude '*', you’re not copying anything, so the Copy task is somewhat pointless here.

The dependencies will be declared on a Configuration like compile, testCompile, etc. The runtime and testRuntime configurations would be what is actually used to run the application or tests (the tutorial is probably outdated referencing those exact configurations, but here’s the relationships: https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_plugin_and_dependency_management).

By specifying the configuration in the from, it causes the configurations to be resolved and downloaded (but not truly copied anywhere other than what happens when resolved).

If a task is desired to just resolve the dependencies, I would write one to do exactly that, not what the tutorial has done. This would do the same thing, but should be more intention-revealing:

task resolveDeps {
    doLast {
1 Like

Thanks a lot!
This task was inside Dockerfile. According to the video course, the intent was to cache the dependencies in Docker layers cache, without exploding the /tmp folder.