Copy Task always gets Skipped and is considered Up-To-Date


(Nitish Kumar) #1

I have a simple copy task:
task(“rs”) {
project.copy{
from(“C:/a.zip”)
into("$buildDir")
}
}
When I run this task, I get output as:
:rs
Skipping task ‘:rs’ as it has no actions.
:rs UP-TO-DATE

1- Why is it always UP-To-Date?
2- Why does it say that it is Skipping task: rs, even though the zip gets copied?
3- Why the incremental build does not work here?


(James Justinic) #2

You have created a task called rs that does nothing upon execution (no actions).

You are manually copying the zip whenever the rs task is configured, not when it executes (as it would if the copy was added as a task action). Minimally, the project.copy { ... } should be wrapped in a doLast { } block to add it as task action, not execute it immediately when any build is run.

The above reasons, plus you don’t have inputs and outputs for the task.

If this is really just a simple copy with no special requirements, you’re better off using the Copy task type instead of essentially re-implementing it:

task rs (type: Copy) {
    from 'C:/a.zip'
    into buildDir
}