可以在相似的目标位置解压来自不同仓库的多个WAR文件吗?

huangapple go评论92阅读模式
英文:

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")
        }
    }
}

}

huangapple
  • 本文由 发表于 2023年2月6日 19:20:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/75360639.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定