It takes a few seconds to finish the process, even there is only one file need to recompile. Because before gradle do any real building job, it has to do some initial work like loading JVM, prepare execution environment, loading Groovy classes etc.
When you frequently change and rebuild, the delay add up.
To resolve this problem, Gradle add a new feature "daemon". The daemon is just a Java application that runs in background thus cut the startup cost.
To start the daemon
gradle --daemon build
You can see the speedup when run with the daemon.
To use the daemon you have to add --daemon option every time running the build.
To let gradle add this option automatically set the environment variable GRADLE_OPTS as this
set GRADLE_OPTS="-Dorg.gradle.daemon=true"
In my experience , this should always be set .
To make sure the daemon is running , if you are under Linux, check with this command
ps | grep gradle
In windows, check it in task manager
It eat 74 MB of my memory. If you finish the development, its better to stop the daemon and free the memory. Its simple
gradle --stop