Depressio
Depressio

Reputation: 1379

Specifying output files for a copy task in Gradle

I have a task which copies a bunch of files from one location into another. It looks like:

task copyStuff (type: Copy) {
    from tempDir
    into buildDir
}

Where tempDir and buildDir are simply Strings. I'm attempting to specify the inputs and outputs of the task to avoid doing it when not necessary, but am having some trouble with the outputs specifically. The inputs are easy:

task copyStuff (type: Copy) {
    inputs.dir tempDir
    from tempDir
    into buildDir
}

But how to specify the outputs in this case? The buildDir can have other things on it, not just the files being copied, so I think I need to specify the outputs.files specifically using the files being copied in. However, I'm unsure of the best way to do that.

Outside of the task, should I loop over the files in the tempDir, and create a list of files similar, but in the buildDir instead? Is there an easier way?

Upvotes: 3

Views: 4697

Answers (1)

Peter Niederwieser
Peter Niederwieser

Reputation: 123910

You don't need to declare inputs or outputs as the Copy task already does it for you. Same for other tasks that ship with Gradle.

Upvotes: 4

Related Questions