gradlebuildbazel

Gradle vs Bazel performance of builds


So everyone is talking about bazel now, but migration to it isn't automated (gradle is better in this regard when migrating from maven). So I don't want to invest time into manually converting any repository to it.

But I can't find any information about build speed difference between recent versions of gradle (5.6 >) and bazel (1.0).

Can anyone share a link or his own experience? I'm mostly interested in incremental builds where just a couple of files have changed.


Solution

  • Okay, I've migrated closed source project containing ~100_000 loc of Java to Bazel.


    Gradle 5.6.3 vs Bazel 1.0.1

    As I've said my interest is about developer productivity and hence about incremental builds.

    I've used the following in BUILD for Bazel so I haven't used most granular approach because I don't think it's really maintainable and that anybody except big companies with a lot of DevOps could use that. And in any case I see the fact that I would need to do this manually to improve build speed as a downside of Bazel.

    java_binary(
        srcs = glob(["src/main/java/**/*.java"]),
        resources = glob(["src/main/resources/**"]),
        ...
    )
    

    Incremental build with one or two changed files:

    I've tried that multiple times and each time Gradle was significantly faster. I haven't tested incremental build when more than one or two files have been changed, maybe in that scenario Bazel would be the same or faster than Gradle.


    No op build

    So speed-wise Gradle seems to be the winner for developer productivity. Bazel have more safe defaults (error-prone is on by default) in Gradle you have to enable it yourself, but IMHO the flexibility of Gradle outweighs more safe defaults of Gazel.