jettyStop is called and executes without an error. However, the next run fails since jetty is not stopped. I found this post Jetty plugin, stopKey not working in daemon mode and double checked the jetty plugin source org.gradle.api.plugins.jetty.AbstractJettyRunTask:
server.start();
if (daemon) {
return;
}
if (getStopPort() != null && getStopPort() > 0 && getStopKey() != null) {
Monitor monitor = new Monitor(getStopPort(), getStopKey(), (Server) server.getProxiedObject());
monitor.start();
}
So how can I stop jetty in daemon mode? I think that the monitor should always be created.
And is it possible to perform jettyStart only when jetty isn’t running to get rid of the startup time?
Do you running jetty with task myTask? If so, after a jetty server is started, the server is shut down. Because myTask depends on jettyRun, and myTask itself do nothing and then the task jettyStop is executed.
There is 2 way to run a jetty server as you want.
Execute only jettyRun, and if you want to stop the server enter CTRL + C(i.e. stop the process).
Launch 2 terminals. One for executing jettyRun, and the other for executing jettyStop when if you want to stop the server.
I didn’t include myTask in my code excerp. Actually, it is not myTask, but bootRun ( a client app in a Spring Boot infrastructure).
Ad 1) Running jettyRun directly will not work, since it is blocking. That’s why the daemon mode is introduced.
Ad 2) I know the two terminal trick, but in my case I would need three terminals, one for starting, one for stopping and one for executing the client app.
Since this is not really comfortable, the daemon mode was introduced and starting works perfect. Jetty gets started and my client task is executed. But since the defect I am mentioning it is not possible to stop Jetty (beside kill), since stopping is not supported in daemon mode. In my opinion the daemon mode is not usable at all because of this limitation.
I am surprised that this is no common problem since this is the typical use case when developing JS apps. Now I understand why grunt and gulp have their place.