Explain syntax of typical "copyToLib" task?


(davidmichaelkarr) #1

I posted a question earlier today asking about just copying dependencies into a lib folder. Someone gave me a helpful reply, which I tried to reply to, but the forum doesn’t appear to let me reply. The button changes from “Reply” to “Replying…” and never finishes. It appears I can post new topics, however, so I guess I’ll just have to post a new topic.

The subject is the following task:

task copyToLib(type: Copy) {
    into "lib"
    from configurations.runtime
}

I’d like to understand more of the syntax and semantics of this. Specifically, what is the purpose and use of the “type” parameter? I know what the “configurations” object is, but what is the “runtime” objects?


(Benjamin Muschko) #2

I’d recommend reading the relevant sections in the user guide:

That should make things much clearer. You might also want to look into books about Gradle, some of which are a) free and/or b) help beginners to Gradle to hit the ground running quickly.


(davidmichaelkarr) #3

I will get to those sections in time. I’m currently just stepping through the “Gradle User Guide”. I note that section 16.6, “Copying Files”, talks about this, but completely fails to explain it. It mentions a “copy spec” without actually saying what that represents, and mentions the CopySpec interface, but doesn’t mention how that enters into the example, as that isn’t seen anywhere.

When you said “books about Gradle” in your response, that’s rendered as a link, but it doesn’t activate as a link, so I’m not sure what that was supposed to be. I did notice “Gradle in Action”, but I’m going to try this “official” user guide first.


(Benjamin Muschko) #4

Fixed the link.