My Gradle project doesn't contain any classes or other configurations. It contains a folder called ExternalLibs
containing other folders. I need to create a war file for each folder present in ExternalLibs
and place it in lib
folder.
Thanks for the help.
Folder structure:
Project Root
|-- ExternalLibs
|-- analyst
|-- storageService
|-- retrievalService
Exepcted output:
Project Root
|-- lib
|-- analyst.war
|-- storageservice.war
|-- retrievalService.war
You can use a task of type Zip
, since War
archive is a Zip
with a fancy extension. You have to create a task per War
, but you can automate it by creating tasks dynamically:
List folders = new File(projectDir, "ExternalLibs").listFiles();
folders.each { dir ->
task "zip${dir.name}"(type: Zip) {
from dir
include '**/*'
destinationDir new File("$projectDir/lib")
archiveName "${dir.name}.war"
}
}
To run all tasks at once, you can create a task that depends on all of them:
task allZips { }
allZips.dependsOn tasks.withType(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.