War plugin causes continuous to run continuously

Hi,

Thanks for your well defined problem report.

There is a known limitation in continuous build that it might trigger a second build when the build directories are “clean”.
For your use case, the workaround is simply to not use “clean” in the targets of the continuous build.

We added the feature to watch for changes that happen during the build in Gradle 2.11 . The “second build getting triggered” problem appears with this feature.

When the task’s input directory doesn’t exist, Gradle cannot watch the directory directly. It has to watch for the directory to get created in the parent directory and if the parent directory doesn’t exist, it first has to wait for that to get created (and so on). This makes things complicated.

Some of the “second build getting triggered” problems appear only on Mac OS X, because the JDK WatchService implementation uses polling on Mac OS X. On Linux or Windows a native file watching implementation is used and the “delayed view” of the file system doesn’t cause problems there. Windows file watching has the ability to watch for a whole file tree (unlike the Linux WatchService) and that causes some other concurrency problems in the change detection.

The fix for the “second build getting triggered” problem in Gradle would be to not watch for intermediate task input directories for changes and only watch for “edge” input directories for changes. In this case the jar/war task are tasks that have intermediate input directories under the “build” directory. However this fix hasn’t been scheduled to be implemented yet.

Lari