Conventional way of copying files in Gradle - use Copy task or copy method?

UP-TO-DATE only verifies the file is in place but not if the files has changed to avoid being cached with an old file use

    outputs.upToDateWhen { false }

In most cases (including this one), the Copy task is the better choice. Among other things, it will give you automatic up-to-date checking. The copy method is meant for situations where (for some reason) you have to bolt on to an existing task and cannot use a separate task for copying.

The code for your Copy task can be simplified to:

task myCopy(type: Copy) {
    from('source')
    into('target')
    include('*.war')
}

Tags:

Gradle