Libin
Libin

Reputation: 97

gradle simple file copy is not working

I'm very new to Gradle and am running this code to copy files from one dir to another ..but it does not work..

 task copyTask (type: Copy) {
    doLast{
        from 'source'
        into 'dest'
    }     
}

The gradle build output

λ gradle copyTask
:copyTask UP-TO-DATE

BUILD SUCCESSFUL

Total time: 1.244 secs

I'm not sure what is it that I'm doing wrong. The files under source dir is not copied to dest dir. Even if there is something wrong with my config why is the copyTask showing as up-to-date ?

Upvotes: 1

Views: 1454

Answers (1)

Regis Alenda
Regis Alenda

Reputation: 499

You should remove the doLast block; it will be executed after the task has been executed. In other words, you are configuring the task after it has run. Gradle is howing UP-TO-DATE as there is nothing to copy.

Try with:

task copyTask (type: Copy) {
  from 'source'
  into 'dest'   
}

Upvotes: 2

Related Questions