2

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?

Dave
  • 15,639
  • 133
  • 442
  • 830

1 Answers1

1

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.

Opal
  • 81,889
  • 28
  • 189
  • 210