Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Buck vs Gradle, pro's and cons for Android build systems

I'm currently using ant to build Android projects but it simply doesn't cut it for larger projects and maintaining different deliverables is becoming a pain.

Two alternatives I'm looking at are Facebook's Buck (http://facebook.github.io/buck/) and Gradle that Google is backing with Android studio (http://tools.android.com/tech-docs/new-build-system/user-guide).

Besides trying them out and reading up on their coverage I would like to ask you fine Stackoverflow people for your recommendations. Preferably if you've used either tool for a while, with bonus points for Buck since it didn't get that much coverage.

Important points are

  • build speed, specifically for dev builds
  • multiple deliverables from same code base
  • ease of use

I'm open to other alternatives as well. What do you suggest and why?

like image 212
Geert Weening Avatar asked May 22 '13 00:05

Geert Weening


People also ask

Why do we use Gradle in Android?

Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.

Do I need Gradle for Android studio?

Gradle is one type of build tool that builds the source code of the program. So it's an important part of Android Studio, and needs to be installed before starting developing your application. We do not have to install it separately, because the Android Studio does it for us, when we make our first project.

What is Buck Android?

Buck is a declarative build system developed & used by Facebook. According to their documentation it encourages the creation of small, reusable modules consisting of code and resources, and supports a variety of languages on many platforms.


2 Answers

As I put front and center in the Buck documentation: "Buck is a build system for Android that encourages the creation of small, reusable modules consisting of code and resources."

By design, Buck encourages you to create small modules so that you can easily compose a new app out of your existing building blocks. This means that maintaining multiple deliverables is straightforward: it eliminates boilerplate without requiring you to organize your repository into a predefined structure. You can also create ad-hoc build steps to suit your needs with Buck via macros and genrules. (A more formalized extension system is in the works.)

We also care a lot about speed, particularly the speed of incremental builds. Because Buck has a strong concept of dependencies, we can often avoid rebuilding intermediate artifacts. Other build systems also try to do this (like Ant), but frequently sacrifice correctness, as a result. We don't.

We recognize that IDE support is important. Certainly Google's collaboration with Gradle gives them a leg up there. However, Buck has a command to generate an IntelliJ project from the dependency graph defined in Buck build files, and we have broken ground on our own IntelliJ plugin, so this is something that we also care deeply about.

Finally, bear in mind that Buck is used to build Facebook, Facebook Messenger, and Instagram for Android. Buck is not going away. Further, the code for all three apps (and reduced versions of the apps, for even faster development cycles) lives in one Git repository at Facebook, so those of us working on Buck internally are sensitive to the needs of large codebases that support multiple deliverables.

like image 80
bolinfest Avatar answered Sep 22 '22 23:09

bolinfest


Long-term, the new Gradle build system will be the standard, and it looks very good. However, it looks like it's not quite ready for use in non-trival projects yet. For instance, it looks like it doesn't support apklib dependencies yet.

This is understandable, and reflected in the fact that the current version is 0.3 I'm looking forward to seeing it evolve.

For a project that needs to be build today, I'd use Maven. Actually, I'm in the process of moving a client's build from Eclipse-only to Maven right now, so that they can have a repeatable build process, good dependency management, and CI. The new Gradle build looks like it will be more flexible, but right now Maven handles apklibs. Since Gradle can use Maven dependencies, I'm expecting that we'll be able to move from Maven to Gradle easily in the future.

I don't know anything about Buck. However, that in itself is a red flag. I'd hesitate to use a build system that few people know anything about. That doesn't mean that it's not good - it may be great. But using it now is probably a gamble.

like image 31
GreyBeardedGeek Avatar answered Sep 24 '22 23:09

GreyBeardedGeek