Skip to content
Advertisement

Zip directory to multiple destinations using Gradle

Is it possible with Gradle’s Zip task to copy the resulting zip into multiple destinations?

AFAIK you can only zip multiple input directories with only one output destination. Is there a way to zip a directory and copy the archive to multiple destinations (in one single task)? Since I’m bound to using Gradle v5.0, a solution for that version of Gradle would be highly appreciated.

Advertisement

Answer

The internal action of Zip tasks will only output the zip file to a single directory. If you don’t want create additional Copy tasks, you may use a doLast closure and use the method copy provided by the Project instance.

task myZip(type: Zip) {
    ...
    doLast {
        copy {
            from archivePath
            into 'path/to/other/destination'
        }
    } 
} 
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement