overlay function of gretty configuration adds the specified project as an overlay source to the current project.


gretty {
  // ...
  overlay ':overlay1'
  overlay ':overlay2'
  // ...


  1. When performing appRun[Debug] and appStart[Debug], runtime classpath of overlay sources is added to the runtime classpath of the current project. Classpath of the current project has priority.

  2. When assembling WAR file, the compiled resources and classes of the overlay sources are added (overlayed) to the current project. The files of the current project have priority over overlay source files. This allows to effectively customize web-app.

You can specify more than one overlay source.
You can specify recursive overlay sources - that is, the projects, added by overlay function, can contain gretty configuration with overlay referencing other projects and so on.
"overlay" property "understands" only gradle projects of the same project tree as an input. You can not specify maven artifacts as overlay sources.

Gretty sources contain example programs, demonstrating use of overlays: