Why I cannot set Copy.destinationDir property?

(aleksg) #1

I cannot understand something in configuring tasks.
For example I create task
task myCopy(type: Copy) {
from(“myDir”) {
rename("$jarName", “$jarFinalName”)

because I see property destinationDir on this page

But I get an error saying

Could not find method destinationDir() for arguments [publish] on task ‘:prepareJar’ of type org.gradle.api.tasks.Copy.

If I change it to ‘into’ then all is well.
Why I have to use ‘into’ instead of property ‘destinationDir’ described in docs?

(Schalk Cronjé) #2

setDestinationDir requires a File object and you are passing a GString. It is better to use into as it takes an Object and allows for lazy-evaluation.

(aleksg) #3

thanks for helping me