Starting with version 1.0.0, Gretty supports unified interface to the servlet containers Jetty 7, 8 and 9, Tomcat 7 and 8. There’s only one plugin to include: org.gretty.

The syntax:

apply plugin: 'war' // optional if you use spring-boot
apply from: 'https://raw.github.com/gretty-gradle-plugin/gretty/master/pluginScripts/gretty.plugin'

gretty {
  // supported values:
  // 'jetty7', 'jetty8', 'jetty9', 'jetty9.3', 'jetty9.4', 'tomcat7', 'tomcat8'
  servletContainer = 'jetty9'
}

or, without "gretty.plugin":

buildscript {
  repositories {
    mavenLocal()
    jcenter()
  }

  dependencies {
    classpath 'org.gretty:gretty:+'
  }
}

apply plugin: 'war'
apply plugin: 'org.gretty'

gretty {
  // supported values:
  // 'jetty7', 'jetty8', 'jetty9', 'jetty9.3', 'jetty9.4', 'tomcat7', 'tomcat8'
  servletContainer = 'jetty9'
}

If you are using Gretty farms, the configuration of servlet container is very similar:

apply from: 'https://raw.github.com/gretty-gradle-plugin/gretty/master/pluginScripts/gretty.plugin'

farm {
  // supported values:
  // 'jetty7', 'jetty8', 'jetty9', 'jetty9.3', 'jetty9.4', 'tomcat7', 'tomcat8'
  servletContainer = 'jetty9'
}

Here are the versions for each servletContainer value:

servetContainer Servlet container version Servlet API version

jetty7

Jetty 7.6.16.v20140903

2.5

jetty8

Jetty 8.1.8.v20121106

3.0.1

jetty9

Jetty 9.2.22.v20170606

3.1.0

jetty9.3

Jetty 9.3.20.v20170531

3.1.0

jetty9.4

Jetty 9.4.6.v20170531

3.1.0

tomcat7

Tomcat 7.0.78

3.0.1

tomcat8

Tomcat 8.0.44

3.1.0

You can override these versions by properties, described in chapter overriding servlet container versions.

When you run generic tasks (appRun, appStart, …​), servletContainer property fully defines on which servlet container your web-app will run. However, you can use more specific tasks to override the chosen servlet container. For example, if you define: gretty.servletContainer = 'jetty9' and run task tomcatRun, your web-app will actually run on tomcat.

For more information see Gretty configuration and Gretty tasks.