tl;dr: If gradle jettyRun fails because of the port still being in use from a prior execution-> configure and use the jettyStop task before by changing your build.gradle.

jettyRun {
    stopKey = "tapJettyStop"
    stopPort = 9087
}

jettyStop {
    stopKey = "tapJettyStop"
    stopPort = 9087
}

jettyRun.dependsOn jettyStop

While developing Apache Tapestry-WebApps with the IntelliJ IDEA-IDE, i couldn’t stop the running the gradle task jettyRun. IDEA seems to run the gradle-task as a daemon in the background. Stopping the task execution from IDEA resulted in jetty still running in the background. To solve this, the gradle jetty plugin brings the task jettyStop, but this doesn’t work out-of-the-box. You have to configure stopKey and stopPort properties to somewhat “connect” the two tasks (jettyStop needs to know which jetty instance to stop). Now it is sufficent to only execute jettyRun. jettyStop is executed automatically prior to every execution of jettyRun.

Leave a Reply

Your email address will not be published. Required fields are marked *