英文:
Is possible to unzip multiple WARs from different repositories in a similar destination?
问题
使用Gradle,我尝试从不同的本地存储库中解压多个WAR文件到同一目标文件夹,但我找不到方法。
根据一些使用zipTree(object)
的解决方案,我做了类似于以下的操作....
task unpackingWar(type: Copy) {
destinationDir = file("$buildDir/generated-resources/unpack/static")
includes = ["**", "*.jsp"]
includeEmptyDirs = false
for (webWar in configurations.webWarUnpacking.files) {
from {
zipTree(webWar)
}
}
}
问题在于这个解决方案总是使用配置列表的最后一个WAR文件覆盖目标目录。我希望将整个WAR文件列表解压到目标目录。
我考虑创建一个包含所有WAR文件并解压它们的ZIP文件,但我想开发一种更优雅的方式。
英文:
Using Gradle I try to unzip multiple WARs from different local repositories into the same destination but I cannot find a way.
According to several solutions using zipTree(object), I did something like....
task unpackingWar(type:Copy){
destinationDir = file("$buildDir/generated-resources/unpack/static")
includes = ["**","*.jsp"]
includeEmptyDirs = false
for (webWar in configurations.webWarUnpacking.files){
from{
zipTree(webWar)
}
}
The point is this solution is always overwritting the destination directory with last WAR of configuration list. I would like to unpack the whole list of WARs into the destination directory.
I thought in creating a ZIP with all WARs and unpacking them but I wanted to develop a more elegant way.
答案1
得分: 0
Finally I found a way using ant.unzip(), worked for me.
tasks.register('unpackWar') {
doLast {
mkdir("build/generated-reources/unpack/static")
for (webWar in configurations.webWarUnpacking.files) {
ant.unzip(src: webWar, dest: "build/generated-reources/unpack/static", overwrite: "false") {
patternset() {
include(name: '')
exclude(name: '/*.jsp')
}
mapper(type: "identity")
}
}
}
}
英文:
Finally I found a way using ant.unzip(), worked for me.
tasks.register('unpackWar') {
doLast {
mkdir("build/generated-reources/unpack/static")
for( webWar in configurations.webWarUnpacking.files) {
ant.unzip(src: webWar, dest:"build/generated-reources/unpack/static", overwrite:"false") {
patternset( ) {
include( name: '**' )
exclude( name: '**/*.jsp')
}
mapper(type:"identity")
}
}
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论