简体   繁体   中英

Gradle: zip files in jar task

I tried to zip files in the jar task but my Zip task is executed during gradle configuration phase. This is my simplified code:

task libZip(type: Zip) {  
     from configurations.runtime  
     archiveName 'lib.zip'  
     println "zip was created"
}  

jar {
     dependsOn libZip
    ... 
    doLast {
       // suggested place to zip files
   }

All works fine but the zip operation takes a "long" time. It should not be executed in configuration phase. Ok, no problem with a "doLast" in libZip task but I wanted the Zip file to be created when I do a "gradle :project:jar". I can`t get it to work to get both.

Please help

好的,我之所以这样,是因为zip不是在配置阶段创建的(我认为是这样),但是只有println“创建了zip”被打印到了控制台。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM