我需要使用Gradle将JAR中的特定文件复制到WAR中的特定目录中。
我的代码:
war.doFirst {
for(file in classpath) {
FileTree tree = zipTree(file)
FileTree treeResources = tree.matching { include "META-INF/resources/*" }
String folderName = 'destinationFolder'
{
treeResources.each {
File resources -> copy {
from resources
String dest = war.destinationDir.name + "/" + war.archiveName + "/" + folderName
into dest
}
}
}
}
问题:“目标”值不正确,而不是在创建的WAR文件中,而是类似“libs / mywar-1.0.war / destinationFolder”。
最佳答案
您会想要类似的东西:
war {
into("destinationFolder") {
from { classpath.collect { zipTree(it) } }
include "META-INF/resources/**"
}
}
关于jar - 如何在Gradle中将文件从JAR复制到WAR?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19166989/