When most of us think about Facebook, open source software probably isn't the first thing that jumps to mind. As it turns out, the social media titan has quite a few public contributions that we rarely hear about. Since Facebook went native, Android development has become a high priority within the company. Among the many pleasant results of this shift, some of the internal tools may find their way into the public domain. One such project is Buck, an alternative build system similar to Ant, but designed to be faster and more modular.


Buck can help you do the following:

  • Speed up your Android builds. Buck builds independent artifacts in parallel to take advantage of multiple cores. Further, it reduces incremental build times by keeping track of unchanged resources so that the minimal set of resources is rebuilt.
  • Introduce ad-hoc build steps for building artifacts that are not supported out-of-the-box using the standard Ant build scripts for Android.
  • Keep the logic for generating build rules in the build system instead of requiring a separate system to generate build files.
  • Generate code-coverage metrics for your unit tests.
  • Generate an IntelliJ project based on your build rules. This makes Buck ideal for both local development builds in an IDE as well as headless builds on a continuous integration machine.
  • Make sense of your build dependencies.
  • Understand what is going on under the hood when building an APK.

Fundamentally, Buck is optimized to speed up large builds by using dependencies to determine which packages can be compiled simultaneously, something Ant was never designed for. Syntax is very similar to Javascript, breaking from the traditional XML format which is often criticized for being error prone and difficult to manage on larger projects. The tool expects all script files to be named BUCK and spread across directories, somewhat like Subversion's files.

These are some samples of BUCK scripts (copied from the website).

If you use IntelliJ for your Android development, it's possible to generate project files and build directly from the IDE. Unfortunately, there's no way to reverse that flow and create BUCK scripts from IntelliJ projects, so everything has to be written by hand. For Eclipse users, Buck won't get in your way, but using it from the IDE will require some extra setup steps.

While there are some benefits to this nifty little tool, one very notable drawback will probably stop most people from using it. Buck is only available on Mac and Linux, and it looks like Windows compatibility will not be coming. The mainstream open source community rarely adopts tools that completely exclude Windows unless it makes sense to do so. Several Ant competitors have turned up in the past, and most have failed to gain traction, so an OS-dependent alternative faces a very difficult uphill challenge. Of course, if a few members of the open source community see enough potential, we may see a Windows port and other enhancements in the future.

For small to medium-sized projects, build times are rarely an issue and most of the work is already done by IDEs. There is definitely potential for Buck to be an asset in larger applications where each compilation can take 15 seconds or longer, but given the limitations, I have my doubts that we will see very many projects relying on it. Still, it's great to see new battle-tested tools emerging as open source projects that may lead to better things down the road.