gretty logo

Gretty is a feature-rich gradle plugin for running web-apps on embedded servlet containers. It supports Jetty versions 7, 8 and 9, Tomcat versions 7 and 8, multiple web-apps and many more. It wraps servlet container functions as convenient Gradle tasks and configuration DSL.

Gretty provides the following features:

Gradle tasks

Gretty provides gradle tasks, which automate starting, stopping, testing and debugging web-apps. Tasks work out-of-the-box, without additional configuration, but are fully configurable/customizable.

See more information at Gretty tasks and Farm tasks.

Spring-boot support

Gretty version 0.0.24+ fully supports spring-boot web-apps. You can run spring-boot web-apps and "normal" web-apps side-by-side on the same servlet container. You can control spring-boot web-apps with the same Gretty configuration and apply all Gretty features to them: integration tests, debugging, Jacoco code coverage etc.etc.

Multiple web-apps support

Gretty version 0.0.18+ supports multiple web-apps feature: it can start arbitrary number of web-apps on the same servlet container. Gretty supports web-apps of various types: gradle projects, WAR-files in the file system and even WAR-files from maven dependencies.

Multiple web-apps feature works out-of-the-box in configureless mode, although it is fully configurable/customizable.

Multiple web-apps feature also works nicely with integration tests and with the debugger.

Gretty version 1.1.0+ supports single sign-on on multiple web-apps (via Jetty and Tomcat realms).

Gretty version 1.1.5+ supports composite farms - farms consisting of other farms.

Switch between servlet container versions

Gretty supports easy switch between Jetty 7, 8 and 9 and Tomcat 7 and 8.

Product generation

Gretty version 1.1.0+ is able to generate runnable products. It works as follows: you invoke "buildProduct" gradle task and Gretty accurately packs one or more web-apps with the specified servlet container (tomcat or jetty), configuration files and, when needed, with spring boot libraries. The generated products are autonomous and self-contained, so they can be deployed to vanilla machines without preinstalled servlet container. The only requirement to the target machine is the presence of JRE 6/7/8.

Hot deployment

Gretty support feature of Hot deployment: When some assets have changed, Gretty automatically reloads your web-app.
There is cool extension to hot-deployment feature in Gretty since version 0.0.18: Gretty automatically recompiles and then reloads your web-app, as soon as source code files have changed.

You can specify that certain folders or files should be fast-reloaded: that is, when they change, they should not cause web-app restart. Instead, the changed files or folders are simply copied into running web-app.

Web-app filtering

Since version 1.1.2-SNAPSHOT Gretty can filter files in "src/main/webapp" the same way as processResources can filter files in "src/main/resources". Gretty sources contain example program demonstrating web-app filtering at work.

Web-app extra resource bases

Since version 1.1.2-SNAPSHOT Gretty supports web-app extra resource bases. It means: additionally to "src/main/webapp" you can specify arbitrary directories that should be served as content of the given web-app. Gretty sources contain example program demonstrating web-app extra resource bases at work.

Web-app overlays

Gretty can generate WAR overlays automatically, each time you build your project. Overlays are also fully supported when running inplace (without WAR) and when debugging.

Virtual WEB-INF/lib entries

Since version 1.1.3 Gretty supports virtual WEB-INF/lib entries. That is: dependency JARs specified in "build.gradle"/dependencies are mapped "on-the-fly" to WEB-INF/lib directory. As a consequence, ServletContext.getResourcePaths("WEB-INF/lib") returns the expected list of JARs, even if you are starting a web-app "inplace", without assembling WAR-file.

HTTPS support

Since version 0.0.23 Gretty supports HTTPS protocol out-of-the-box. All you have to do is set property httpsEnabled=true. Gretty does all heavy-lifting for you: generates necessary cryptographic key, generates X.509 certificate, configures SSL-connector. Of course, you can fully customize HTTPS protocol via Gretty configuration properties or even via "jetty.xml".

Debugger and integration tests support

Gretty provides integration with Java IDE debuggers. You can even debug multiple web-apps loaded into the same servlet container.

Gretty supports integration tests: it starts servlet container before integration tests and stop it after. Gretty version 0.0.22+ supports Jacoco code coverage of web-app projects - both client-side and server-side. The resulting coverage information can be converted to report with the help of standard gradle task JacocoReport.

Gretty version 1.1.5+ supports [override of context path in integration test tasks](http://akhikhl.github.io/gretty-doc/Override-context-path-in-integration-test-tasks.html).

Injection of version variables

Gretty version 1.1.5+ automatically injects some version variables into project.ext of your project.

Logging support

Gretty provides Logging out-of-the-box, although it does not force it on your web-app.

JEE features

Gretty supports JEE annotations out-of-the-box, no effort needed.

Gretty supports Web fragments: META-INF/web-fragment.xml and META-INF/resources in dependency libraries - both in inplace and WAR tasks.

Gretty version 1.1.7+ implements new feature: redirect filter, driven by groovy DSL. You can configure and use the redirect filter within any web-application, even if you deploy web-application as a WAR file to arbitrary servlet container (without Gretty).

Jetty-specific features

Gretty automatically uses "jetty.xml" and "jetty-env.xml", if they are present.
Gretty also supports Jetty security realms out-of-the-box.

Tomcat-specific features

Gretty automatically uses "tomcat.xml" and "tomcat-context.xml", if they are present.
Gretty also supports Tomcat security realms out-of-the-box.