Gradle Jetty plugin locking files

gradle, jetty

Solution

Kiril answered his own question, many thanks. You should follow Kiril's instructions and this will help you find the appropriate `webdefault.xml`.

To find out what version of Jetty is started by Gradle, execute

gradle jettyRun -i

And you'll see something like this:

...
Tmp directory =  determined at runtime
Web defaults = org/mortbay/jetty/webapp/webdefault.xml
Web overrides =  none
Webapp directory = C:\dev\my-project\src\main\webapp
Starting jetty 6.1.25 ...
jetty-6.1.25
...

It took me a while to find a copy of Jetty 6.1.25 as it is no longer listed on the Jetty download page (not even in the archive section!).

You can then grab the appropriate copy of `webdefault.xml` from here, adjusting the version number as appropriate for your needs:

http://grepcode.com/file/repo1.maven.org/maven2/org.mortbay.jetty/jetty/6.1.25/org/mortbay/jetty/webapp/webdefault.xml

Problem

Is there a way to fix the file locking issue caused by `jetty` entirely from `gradle`? Some clarification: When using the Gradle Jetty plugin by running `gradle jettyRun,` jetty causes the static resource files (html, css, js, etc.) to be locked when using Windows. You can see a description of the problem in Files locked on Windows. The same article also describes how you can fix that. Basically you have to either: - Disable the use of file mapped buffer - Not use NIO at all. Both things require to add some jetty specific configuration files to the project, which I do not want to do - the jetty plugin is used only for convenience, and maintaining configuration for it does not feel right. I do not need NIO for testing on the local machine, so any solution works. Edit: For now, I picked the option at which you set `useFileMappedBuffer` to `false`. This is how to do it: Specify a path to your `webdefault.xml` like ``` [jettyRun, jettyRunWar,jettyStop]*.with { //other configs webDefaultXml = file("${project.webAppDir}/WEB-INF/jetty-webdefault.xml") } ``` Get file from the latest 6.1.x distribution of jetty. The plugin seems to support only jetty 6. You can localte it at `jetty-6.1.26\etc\webdefault.xml`. Obviously, you have to place it at the path specified at the previous step. Change the default servlet init parameter `useFileMappedBuffer` to `false` I will research the option of using embeded jetty insted of the plugin.

Original source