I’m using Gradle 2.7. I would like to copy an environment-specific file (context.xml) into my WAR’s META-INF directory (which is at the same level as WEB-INF). I have this task set up in my build.gradle file
// Copy context.xml into the appropropriate directory.
war {
def env = project.hasProperty('env') ? project.env : 'dev'
from("${project.rootDir}/src/main/environment/$env") {
include('context.xml')
into('META-INF')
}
}
However, when I run “gradle build”, nothing gets copied. I have verified the file exists. What else do I need to do to get this file to copy properly?
It seems that your script is configured correctly. It's stupid question (it should've failed at the very beginning) but have you applied war
plugin?
Here you have a demo to compare the configurations.
Run:
jar -tvf <lib>.war
to verify if war contains appropriate file.