Reputation: 3930
I need to copy specific files that are in JARs into specific directory in WAR, using Gradle. My code:
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
}
}
}
}
Problem: the "dest" value is incorrect, instead of being in the created WAR file, it is something like "libs/mywar-1.0.war/destinationFolder".
Upvotes: 0
Views: 2485
Reputation: 123910
You'll want something like:
war {
into("destinationFolder") {
from { classpath.collect { zipTree(it) } }
include "META-INF/resources/**"
}
}
Upvotes: 1