Tasks have to be configured in the configuration phase. However, you are configuring it in a task action (<< { ... }
), which runs in the execution phase. Because you are configuring the task too late, Gradle determines that it has nothing to do and prints UP-TO-DATE
.
Below is a correct solution. Again, I recommend to use doLast
instead of <<
because it leads to a more regular syntax and is less likely added/omitted accidentally.
task backupFile(type: Copy) {
from file(adjusting_file.replaceAll("\"", ""))
into file(backupDestinationDirectory + "/main/")
doLast {
println "[INFO] Main file backed up"
}
}