I’ve written a lot of blogs about how to do certain technical things in Gradle, in this blog I will compare the performance features of Gradle to that of Maven’s. As of Gradle 2.5 and Maven 3.3.3 Gradle supports incremental builds, where Maven does not. Gradle’s incremental builds work off the simple concept of re-building the components that have changed, not the whole project every single time. They accomplish this by their state-of-the-art build intelligence, up-to-date checks and caching. Gradle is able to tell if a task is “up-to-date” depending on if the input and output of the task has changed.
Another key performance enhancer that Gradle has introduced has been the Gradle daemon, which is a forked background process that stays alive for a set amount of time after a build is run. Having this daemon active practically cuts Gradle’s startup time to zero. It is important to note that Gradle strongly discourages the use of the daemon in a continuous integration environment, because the daemon does not guarantee stability and isolation. Another way Gradle has increased the performance of their builds is to enable parallelization across many different aspects of the build life cycle.
The first place that they allow for parallelization is at the project level. Gradle allows for subprojects to be built in parallel, this works only if your dependencies are correctly defined. NOTE: Although Gradle can be optimized very well, it can also go wrong very quickly. In large and complicated systems, it is important that you audit changes to the dependency graph, I’ve seen builds go from 45 minutes to 25 minutes then balloon back up to around 60 minutes due to mishandling of the dependency graph. An easy way to do this is to set up a Gradle task to use graphviz. The next level that Gradle allows for is at the task level, which works out-of-the-box. It is defaultly enabled, although Gradle does caution its use at it is based of their experimental new configuration model. All of the aforementioned features that Gradle offers, starting at version 2.5, are not available with Maven 3.3.3 and with all these features, it is safe to say that Gradle committed to blowing Maven’s performance out of the water.

Leave a comment

Your email address will not be published. Required fields are marked *

X