When you apply gretty plugin, it adds gretty extension to the project. You can (but you don’t have to) customize every aspect of gretty plugin with the help of gretty DSL:

gretty {
  port = 8081
  contextPath = '/MyWebApp'
  // ... many more properties
}

All gretty tasks, when invoked on given project, use properties of gretty extension.

If you don’t specify any properties in gretty extension (or omit it altogether), gretty tasks run with reasonable defaults.

Server-specific properties

Gretty extension supports the following server-specific properties:

Property Type Default Purpose

jvmArgs

List<String>

[]

Additional JVM arguments to servlet-container process.

servletContainer

String

'jetty9'

Servlet container to be used in appXXX tasks. Possible values are 'jetty7', 'jetty8', 'jetty9', 'jetty93' (jdk 8 only), 'jetty94' (jdk 8 only), 'tomcat7', 'tomcat8'.

managedClassReload

boolean

false

When true, Gretty gradle tasks facilitate your web-app with springloaded library, thus allowing to live-reload compiled classes and avoid restarting servlet container.
See also: Hot deployment.

host

String

"localhost"

host is passed to servlet-container connectors. If you use HTTPS, host must match CN of the subject DN of the certificate (if you use HTTP auto-configuration, Gretty ensures this automatically).

httpEnabled

boolean

true

When httpEnabled is true, Gretty configures HTTP connector for the designated httpPort. Otherwise HTTP protocol is disabled. Normally either httpEnabled or httpsEnabled should be true.

httpPort

int

8080

TCP-port used by servlet-container for incoming HTTP-requests.

port

int

8080

This property is deprecated, please use httpPort instead

httpIdleTimeout

int

null

When not null, defines the time, in milliseconds, that the HTTP connection can be idle before it is closed.

httpsEnabled

boolean

false

When httpsEnabled is true, Gretty configures HTTPS connector for the designated httpsPort. Otherwise HTTPS protocol is disabled. Normally either httpEnabled or httpsEnabled should be true.
See also: HTTPS support.

httpsPort

int

8443

TCP-port used by servlet-container for incoming HTTPS-requests.
Attention: setting httpsPort alone is not enough to enable HTTPS protocol. You must set httpsEnabled=true in order to enable HTTPS.

sslKeyStorePath

String or java.io.File

null

Absolute or relative path to the key-store, containing key and certificate for HTTPS connection. If sslKeyStorePath is not specified, all other SSL-related properties are ignored and HTTPS is auto-configured (if it is enabled).
See also: HTTPS manual configuration

sslKeyStorePassword

String

null

Password for the key-store designated by property sslKeyStorePath.
See also: HTTPS manual configuration

sslKeyManagerPassword

String

sslKeyStorePassword

Password for the key of this host, stored in key-store designated by property sslKeyStorePath.
See also: HTTPS manual configuration

sslTrustStorePath

String or java.io.File

sslKeyStorePath

Absolute or relative path to the trust-store for HTTPS connection.
See also: HTTPS manual configuration

sslKeyStorePassword

String

null

Password for the key-store designated by property sslKeyStorePath.
See also: HTTPS manual configuration

sslNeedClientAuth

boolean

false

Specify if client auth is required

httpsIdleTimeout

int

null

When not null, defines the time, in milliseconds, that the HTTPS connection can be idle before it is closed.

serverConfigFile

String or java.io.File

"jetty.xml" or "tomcat.xml"

Name and/or location of servlet-container-specific server configuration file.
See also: jetty.xml support and tomcat.xml support.

jettyXmlFile

String or java.io.File

"jetty.xml"

This property is deprecated, please use serverConfigFile instead.

scanInterval

int

1

Hot-deployment scan interval, in seconds.
See also: Hot deployment.

logbackConfigFile

String

"logback.groovy" or "logback.xml"

Absolute or relative path to logback configuration file (.groovy or .xml).
See also: Logging.

loggingLevel

String

"INFO"

slf4j logging-level for servlet-container process.
See also: Logging.

consoleLogEnabled

boolean

true

Defines whether log messages are written to the terminal.
See also: Logging.

fileLogEnabled

boolean

true

Defines, whether log messages are written to the log-file.
See also: Logging.

logFileName

String

"${project.name}.log"

Log file name (without path).
See also: Logging.

logDir

String

"${user.home}/logs"

Directory, where the log file is created.
See also: Logging.

onStart

function(Closure)

-

Adds closure to be called just before servlet-container is started.

onStop

function(Closure)

-

Adds closure to be called just after servlet-container is stopped.

onScan

function(Closure)

-

Adds closure to be called on hot-deployment scan.
See also: Hot deployment.

onScanFilesChanged

function(Closure)

-

Adds closure to be called whenever hot-deployment detects that files or folders were changed.
See also: Hot deployment.

servicePort

int

9900

TCP-port used by Gretty to send commands to servlet-container process.

statusPort

int

9901

TCP-port used by servlet-container process to send status back to Gretty.

interactiveMode

String

stopOnKeyPress

Defines Gretty’s reaction on user keypress. When 'stopOnKeyPress', any keypress stops running web-server. When 'restartOnKeyPress', any keypress causes web-server restart. When 'rebuildAndRestartOnKeyPress', any keypress causes Gretty to rebuild web-apps and then restart web-server.
Note that interactiveMode only affects interactive tasks: appRun, appRunDebug, farmRun, farmRunDebug etc. Tasks having word "start" in their name are non-interactive and must be stopped by respective stop tasks. See more information on Gretty tasks here.

springBootVersion

String

1.1.7.RELEASE

Defines which version of SpringBoot must be used with the given web-server/web-app.

enableNaming

boolean

false

When true, Tomcat supports JNDI resource naming.

redeployMode

String

restart

Defines Gretty behaviour on application redeployment. When 'restart' gretty simply restarts servlet container. When 'redeploy' gretty redeploys web application on servlet container. Redeploy is useful when multiple application is started in farm mode.

scanner

String

jetty

Switch between jetty and jdk scanners. 'jetty' is scan-based and 'jdk' is notify-based (jdk 7).

auxPortRange

List<Integer>

null

If specified gretty will pick service and status port from it.

portPropertiesFileName

String

gretty_port.properties

Specifies name of file for gretty service and status port.

Web-app-specific properties

Gretty extension supports the following web-app-specific properties:

Property Type Default Purpose

contextPath

String

"/${project.name}"

Context path for the web-app.
contextPath affects only gretty tasks. If you assemble WAR file and deploy it to some servlet container, you must define context path by means of that container.

[[__beforeclasspath] beforeClassPath

function(URL…​ url)

-

Adds classpath entry before web-app classpath
beforeClassPath affects only gretty tasks (not the generated WAR files or products).

classPath

function(URL url)

-

Add classpath entry to the web-app.
classPath affects only gretty tasks (not the generated WAR files or products).

initParameter

function(String key, String value)

-

Adds web-app initialization parameter.
It has the same meaning/effect as /web-app/servlet/init-param element in "web.xml". initParameter affects only gretty tasks. If you assemble WAR file and deploy it to some servlet container, you must define init-parameters in "web.xml".

contextConfigFile

String or java.io.File

"jetty-env.xml" or "tomcat-context.xml"

Name and/or location of servlet-container-specific context configuration file.
See also: jetty-env.xml support and tomcat-context.xml support.

jettyEnvXmlFile

String or java.io.File

"jetty-env.xml"

This property is deprecated, please use contextConfigFile instead.

realm

String

null

Security realm for the given web-app.
See also: Jetty security realms and Tomcat security realms.

realmConfigFile

String or java.io.File

"jetty-realm.properties" or "tomcat-users.xml"

Contains security realm properties for the given web-app.
See also: Jetty security realms and Tomcat security realms.

scanDir

function(String) or function(java.io.File)

-

Adds a directory to the list of directories scanned by hot-deployment.
See also: Hot deployment.

fastReload

boolean or function(String) or function(java.io.File) or function(Map)

true

Adds folders to be fast-reloaded on change, i.e. copied to running web-app without restarting web-app.
See also: Fast reload.

recompileOnSourceChange

boolean

true

Should the given web-app automatically recompile on source change?
See also: Hot deployment.

reloadOnClassChange

boolean

true

Should the given web-app automatically reload when it’s compiled classes change?
See also: Hot deployment.

reloadOnConfigChange

boolean

true

Should the given web-app automatically reload when configuration files (either in WEB-INF or META-INF) change?
See also: Hot deployment.

reloadOnLibChange

boolean

true

Should the given web-app automatically reload when library files (either in WEB-INF/lib or in maven dependencies) change?
See also: Hot deployment.

inplaceMode

String

"soft"

Can be "soft" or "hard" (default "soft"). When "hard", the web-server serves the resources (of the given web-app) directly from src/main/webapp. When "soft", the web-server serves the resources (of the given web-app) from build/inplaceWebapp.
Attention: inplaceMode="hard" effectively disables webapp overlays and webapp filtering.
See also: Hot deployment.

overlay

function(String) or function(Project)

-

Adds another project (in the same project tree) as overlay source.
See also: Web-app overlays.

integrationTestTask

String

"integrationTest"

Name of gradle task in the same project, which gretty "encloses" with servlet-container start/stop.
See also: Integration tests support.