I want to create 1aa.zip, 2aa.zip and 3aa.zip, but all I get is 3aa.zip. How to loop and create three different zip files? I am a gradle newbie, any advice please. Thanks in advance
task myZip(type: Zip) {
List a=[1,2,3]
for(int num:a) {
myZip {
from '/Users/sbam/repos/Config/myfolder'
include '*.*'
destinationDir new File('/Users/sbam/repos/Config/myfolder/out')
archiveName num+"aa.zip"
}
}
}
List a=[1,2,3]
a.each { num ->
task "myZip$num"(type: Zip) {
from '/Users/sbam/repos/Config/myfolder'
include '*.*'
destinationDir new File('/Users/sbam/repos/Config/myfolder/out')
archiveName num+"aa.zip"
}
}
‘gradle myZip1’ or ‘gradle myZip2’ or ‘gradle myZip3’, depending on which task you want to execute. You can also add a composite task: ‘task allZips { dependsOn tasks.withType(Zip) }’.