It’d be really useful to be able run Gradle in daemon mode, but have it ‘watch’ one or more directories. When a change occurs in one of those directories, it would then trigger a Gradle build with a set of tasks (configurable).
Another use case: I’m building a Spring MVC app. I’d like Gradle to automatically build my project when I save changes, so that I can quickly determine when I introduce a breaking change. Admittedly, this use case is a little weaker (who would want to have build failures when you have a partially completed file?).
This indeed would be a useful feature, and is something that we’ve been talking about internally for some time. Unfortunately, it’s not really feasible to do this with Gradle today.
You’ll have to find an external process that watches for changes and kicks of the Gradle build. You could either kick off the Gradle build via the command line, or via the Tooling API.
Thanks for the well written suggestion! What you are describing is a highly desirable feature that has been discussed before and is definitely on our list. The fact that Gradle tasks already know, or can be made to know, all their inputs will make this an even more compelling feature.
I wrote a “Proof-of-concept” plugin for this, (https://github.com/ylemoigne/gradle-continuous-plugin)
Anyone from gradleware can tell me if I’m going in the right direction ?
That’s an interesting implementation. I’ve added some comments on GitHub.
How do you find that it works in practice?
Thanks for your comment. I will rework my plugin soon.
In practice, it work correctly.
The most annoying point is that task like ‘compileJava’ return list of java sources as input, not the sourceSets, so hoping to use only task input to declare watches is quite compromised.
Hi, Any new info regarding this?
Hi, any new info about this?
Nice, I got it working in just couple of minutes for compiling TypeScript. So far works like a charm