Andrey Hihlovskiy

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

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!

10 responses to “Meet Gretty: advanced gradle plugin for running web-applications under Jetty and Tomcat

  1. Michael Snell July 29, 2013 at 12:53

    Hi Andrey – I’d like to try this out, but it doesn’t look like you’ve released a build to Maven yet?

    • akhikhl July 30, 2013 at 11:02

      Hi Michael,

      Yes, please, feel free trying it. Please, have a look at the examples – they are easily compilable and show different aspects of gretty at work.

      No, I’m not planning to port gretty to maven. Quite reverse – I move most of my projects from maven to gradle, in order to reduce development/maintenance costs. For example, I was able to get rid of Eclipse Tycho and replace it with far simpler build configuration, which works like a charm and does not require huge efforts to implement.

      From technical point of view: there is so-called Jetty Maven Plugin, which already provides adequate functionality for maven projects ( ). What I understood from their documentation, latest Jetty Maven Plugin also supports WAR overlays.

      So, think of it as follows: gretty is the same, as Jetty Maven Plugin, but for gradle builds.

      I wish you a nice day!

      • Michael Snell July 30, 2013 at 11:22

        Hi Andrey – Sorry, I wasn’t clear, I meant that you haven’t released a version to the Maven Central Repository, so I can’t just add it as a buildscript.dependency to my Gradle config – instead I have to clone your Git repository, tweak it and push a release to a local Maven repository (ie Sonatype Nexus) to use it.

      • akhikhl July 30, 2013 at 11:53

        Ah, now I got it 🙂

        Yes, I will push things to maven central.

        As a temporary solution, please add the following to your gradle project:

        repositories {
          maven {
            url ''

        and then you can test gretty.

        Important: please make sure that this repository is added both to buildscript and to project. The reason for it is the following: gretty introduces compile-time extensions (gretty element in build.gradle), as well as runtime dependencies (so that jettyRun, jettyStop etc. can be started). Also it is worth mentioning that gretty does not modify the target project with jetty-specific compile-dependencies. Gretty adds only one new compile-dependency, this is providedCompile ‘javax.servlet:javax.servlet-api:3.0.1’.

    • akhikhl January 8, 2014 at 18:52

      Hi Michael,
      If you still have interest in Gretty – it is now on maven central!
      The sources and documentation here:
      Script for include or copy to gradle is here:
      Wish you all the best!

  2. bruce January 8, 2014 at 15:58

    i got this message:logback config file is not detected, gretty will configure logback,why?

    • akhikhl January 8, 2014 at 19:04

      Hi Bruce,
      It’s not a bug, it’s a feature 🙂
      This means the following: Gretty tried finding one of two files – “logback.xml” and “logback.groovy” – in the folders designated by project.sourceSets.main.output.files (typically these would be “build/classes/main” and “build/resources/main”) and did not find them.
      The purpose of this message is the following: to notify a programmer, that, since logback configuration wasn’t found, Gretty will try to configure it itself.
      The message does not affect functionality of Gretty or of your program – it is related to logging only.
      Does your project contain “logback.xml” or “logback.groovy”? If so, then in which folder?

  3. nick May 22, 2014 at 12:39

    Hi Michael,

    One area where the existing jetty plugin is weak is when doing code coverage with jacoco.

    Do you know if gretty interoperates well with jacoco, and if so, maybe could you add an example showing this?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: