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".

Syntax

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

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

Effects

webappCopy closure is automatically invoked when:

  • gradle performs one of Gretty run tasks

  • gradle builds WAR file

  • gradle builds a product

Tip
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.