Google just open-sourced its build tool Bazel. What are the differences between this tool and Gradle? What can it do that Gradle cannot, what does it do better, and what does Gradle do better?
Disclaimer: I work on Bazel and I'm not intimately familiar with Gradle. However, one of my coworkers wrote up a comparison of the two systems, which I will paraphrase here:
Bazel and Gradle emphasize different aspects of the build experience. To some extent, their priorities are incompatible - Gradle’s desire for flexibility and non-obtrusiveness limits the restrictions it can place on build structure, while Bazel's desire for reliability and performance necessarily enforces non-negotiable restrictions.
Gradle does value the same principles that Bazel does, i.e. the Gradle team pays great attention to performance (incremental builds, parallelized configuration and execution, the Gradle daemon), correctness (content-based “up-to-date” checking), and reproducibility (rich support for declarative syntax, dependency versioning, explicitly declared dependencies). And Bazel respects the need for flexible project layouts.
The nuance is that Gradle wants to promote good practice while Bazel wants to require it. Gradle aims for a middle ground between the Ant experience (freedom to define your own project structure with incoherent results) and the Maven experience (enforced best practices with no room for varying project needs). Bazel believes that flexible project support is possible without sacrificing the strong guarantees that enable its powerful workflows.
Neither philosophy is more “correct” - whichever tool best suits a project depends on that particular project’s values.
Gradle is a highly flexible system that makes it easy for users to construct complete, reliable build flows with minimal constraints on how they organize their projects. It does this by supplying powerful building blocks (e.g. automatic dependency tracking and retrieval, tightly integrated plugin support) with a generic, Turing-complete, scripting interface that can combine these blocks however the users wants.
Gradle emphasizes the following features:
Bazel evolved out of the need to build internal Google projects reliably and efficiently. Because Google’s development environment is unusually large and complex, Bazel offers unusually strong guarantees about the integrity of its builds and unusually low performance overhead in achieving them.
This provides a foundation for powerful development workflows built around reproducible builds, where a “build” becomes an abstract entity that can be referenced, repeated, passed around to different machines, and passed to arbitrary programs and services such that every instance is known to be exactly the same.
Bazel emphasizes the following features: