Andrey Hihlovskiy

Professional blog on groovy, gradle, Java, Javascript and other stuff.

Category Archives: jetty

Powerful feature in Gretty 0.0.24 – full support of Spring Boot 1.1.0

Today is a wonderful day: Spring Boot 1.1.0 was released and I released Gretty version 0.0.24.

Gretty is a feature-rich gradle plugin for running web-apps on Jetty. It supports multiple Jetty versions (7, 8 and 9), multiple web-apps and many more. It wraps Jetty functions as convenient Gradle tasks and configuration DSL. A complete list of Gretty features is available in feature overview.

There is new powerful feature in Gretty 0.0.24: it supports running Spring Boot web-apps out-of-the-box. All Gretty features, including (but not limited to) debugging, code coverage and integration tests, also apply to spring-boot web-apps.

Simplest Gretty setup with Spring Boot:

You get Gretty as maven artifacts at jcenter and maven central under the group “org.akhikhl.gretty”.

Full Gretty sources and examples are available at

Full Gretty documentation is available at


Killer feature in Gretty version 0.0.18 – multiple web-apps support

Let’s assume, you are developing web-applications with JVM-based languages and technologies and are looking for the solution of the following problem:

You have a bunch of web-apps, that must run all at the same time, because they call each other. You also want to debug multiple web-apps and even run integration tests – on the complete bunch.

Here is the solution to this problem: use Gretty. This is gradle plugin, capable of exactly this: running multiple web-apps, debugging, integration tests. Of course, it is open-source and available at jcenter and maven central.

Gretty can start arbitrary number of 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.

The central concept of Multiple web-apps feature is farm – a collection of web-apps, that should run together.

There are two ways to define and use farms:

  • Default farm is automatically created for you by Gretty. You may add artbitrary web-apps to it and then invoke farm-specific tasks: farmRun, farmRunDebug, etc. Note that farm-specific tasks are not using gretty tasks (jettyRun, jettyRunDebug, etc.), but they understand and use gretty configurations.
  • Named farms, which you create yourself in gradle script. You can add as many named farms as you want, and you can add web-apps to farms in arbitrary constellations. Each named farm provides a specific set of farm tasks. For example, if you define farm with name “XYZ”, there will be new tasks farmRunXYZ, farmRunDebugXYZ, etc. available.

You can start using multiple web-apps support right away, using the following scenario as a starting point:

Create three empty folders: ProjectA, ProjectB and ProjectC, so that folder tree looks like this:

|-- ProjectB
\-- ProjectC

Create file “ProjectA/settings.gradle”, insert code:

include 'ProjectA', 'ProjectB'

Explanation: we organize multi-project setup, so that multiple web-apps can be started/stopped by gretty-farm plugin.

Create file “ProjectA/build.gradle”, insert code:

buildscript {
  repositories {

  dependencies {
    classpath 'org.akhikhl.gretty:gretty-plugin:+'

apply plugin: 'gretty-farm'

Create file “ProjectA/ProjectB/build.gradle”, insert code:

apply plugin: 'gretty'

Create file “ProjectA/ProjectC/build.gradle”, insert code:

apply plugin: 'gretty'

Done! Now you can run multiple web-apps by running the following command in ProjectA:

gradle farmRun

Expected output:

Jetty server 9.1.0.v20131115 started.
:ProjectB runs at the address http://localhost:8080/ProjectB
:ProjectC runs at the address http://localhost:8080/ProjectC
servicePort: 9900, statusPort: 9901
Press any key to stop the jetty server.

Of course, you’ll get 404 in the browser, because web-apps don’t contain any pages. But, as soon as you add pages or/and servlets to the web-apps, things will get real.

By default farm automatically adds all subprojects of the farm project, which are facilitated with gretty plugin, to web-apps list. You can also explicitly add web-apps to the given farm.

Gretty-farm plugin defines new, distinct set of tasks for running farms: farmRun, farmRunDebug, farmRunWar, farmRunWarDebug, etc.

Gretty version 0.0.15 is out!

I release Gretty (gradle plugin for jetty) version 0.0.15!

New: fast-reload of webapp-resources, jdk8-compatibility.

Sources and documentation at

Also available on jcenter & maven central!

Gretty 0.0.14 is out!

Hello there,

Gretty version 0.0.14 is out – on github, on maven central and jcenter!

What’s new: now Gretty supports jvmArgs parameter in plugin extension. See more information in what’s new section of the documentation.

Gretty is a feature-rich Gradle plugin, designed for running Web-Applications on Jetty. See more information in main features section of the documentation.

Many thanks to Justin Munn for contribution!

Gretty version 0.0.13 is out!

Gretty is a feature-rich gradle plugin for running web-applications under jetty.

New in version 0.0.13:

  • support of META-INF/web-fragment.xml and META-INF/resources
  • integration tests for most of the examples
  • integration of the build scripts with bintray and availability of the new version on jcenter

Full sources, documentation and examples:

Gretty 0.0.13 artifacts are available both on maven central and on jcenter under the group “org.akhikhl.gretty”.

Gretty version 0.0.11 is out!

Gretty is a feature-rich gradle plugin for running web-applications under jetty.

New in version 0.0.11: now it’s possible to specify logback configuration file (.groovy or .xml) via plugin extension property “logbackConfigFile”.

Full sources, documentation and examples:

Gretty 0.0.11 is also available on maven central under group “org.akhikhl.gretty”.

groovy script for running jetty server

The following script starts jetty server and opens the folder, specified on command line, for http access (read-only):

#!/usr/bin/env groovy

@Grab(group='org.eclipse.jetty', module='jetty-webapp', version='8.1.8.v20121106')
@Grab(group='org.eclipse.jetty', module='jetty-server', version='8.1.8.v20121106', transitive=false)
@Grab(group='org.eclipse.jetty', module='jetty-servlet', version='8.1.8.v20121106', transitive=false)

import org.eclipse.jetty.server.Server
import org.eclipse.jetty.servlet.*
import groovy.servlet.*

def publishedFolder = args ? args[0] : '.'

def server = new Server(8080)
def context = new ServletContextHandler(server, '/', ServletContextHandler.SESSIONS)
def webappContext = new org.eclipse.jetty.webapp.WebAppContext(publishedFolder, '/jetty')
println 'Jetty server started. Press Ctrl+C to stop.'


  1. Save this script to file “jetty.groovy”
  2. Invoke on command-line:
    groovy jetty.groovy /path/to/some/folder"
  3. Enter address in web-browser:

Expected result: you see the content of the folder “/path/to/some/folder” in the web-browser.

Meet Gretty: advanced gradle plugin for running web-applications under Jetty and Tomcat

I created little gradle plugin for running web-applications under Jetty 8.1.8.

The main advantage for a programmer is that now it’s possible to use servlet-api 3.0 and higher (under standard gradle-jetty plugin it was not possible, because jetty was too old).

Full sources, documentation and examples here:

Update 24.02.2014:

Now gretty supports jetty 7, 8 and 9 and servlet API 2.5, 3.0.1 and 3.1.0, as well as it brings many new interesting features!

Update 07.10.2014

Now Gretty supports Tomcat 7 and 8, as well as SpringBoot, spring-reloaded and jacoco!