Since version 1.1.2 Gretty can filter files in "src/main/webapp" the same way as processResources can filter files in "src/main/resources".


gretty {
  webappCopy { CopySpec copySpec ->
     // ...

here webappCopy is a closure, accepting org.gradle.api.file.CopySpec as a parameter.


webappCopy closure is automatically invoked when:

  • gradle performs one of Gretty run tasks

  • gradle builds WAR file

  • gradle builds a product

There’s no need to duplicate CopySpec-specific code in gretty and War task. You can hold all filtering code in gretty.webappCopy. Gretty automatically reconfigures War task with gretty.webappCopy.

Gretty sources contain example program demonstrating web-app filtering at work.