---
title: "Enabling Kotlin incremental compilation on Buck2"
description: "Meta integrated the Kotlin incremental compiler into Buck2 via Kotlin's experimental Build Tools API, making some large Android modules build up to 3x faster and improving incremental build times about 30% for the average developer."
url: "https://swe.quest/articles/enabling-kotlin-incremental-compilation-on-buck2-bd5307852c0570ff"
canonical: "https://engineering.fb.com/2025/08/26/open-source/enabling-kotlin-incremental-compilation-on-buck2/"
source: "Meta Engineering"
published: "2025-08-26"
difficulty: "medium"
kind: "Case study"
reading_minutes: 10
tags: ["build-systems","jvm","compilers","developer-productivity","mobile"]
---

# Enabling Kotlin incremental compilation on Buck2

A post on [Meta Engineering](https://swe.quest/sources/meta.md), published 2025-08-26, 10 min read, Case study. Original: [https://engineering.fb.com/2025/08/26/open-source/enabling-kotlin-incremental-compilation-on-buck2/](https://engineering.fb.com/2025/08/26/open-source/enabling-kotlin-incremental-compilation-on-buck2/)

## Summary

Meta integrated the Kotlin incremental compiler into Buck2 via Kotlin's experimental Build Tools API, making some large Android modules build up to 3x faster and improving incremental build times about 30% for the average developer. The work involved migrating the toolchain to the shaded kotlin-compiler-embeddable, using Buck2 incremental actions to keep prior outputs and compute changed-file lists from input hashes, making the cache relocatable for remote execution, and generating classpath snapshots as a separate cacheable action. Custom compiler plugins had to be made incremental and accumulate results across multiple compilation rounds. jvm-abi-gen still lacks incremental support, so a stopgap merges the new ABI with the previous output.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)
- [Java & JVM](https://swe.quest/tags/jvm.md) (Languages)
- [Compilers](https://swe.quest/tags/compilers.md) (Compilers & runtimes)
- [Developer productivity](https://swe.quest/tags/developer-productivity.md) (Engineering practices)
- [Mobile](https://swe.quest/tags/mobile.md) (Web & mobile)

## Prerequisites

- Kotlin compilation ([easy posts on Java & JVM](https://swe.quest/tags/jvm.md?difficulty=easy))
- build systems like Bazel/Buck ([easy posts on Build systems](https://swe.quest/tags/build-systems.md?difficulty=easy))
- JVM classpath and shading ([easy posts on Java & JVM](https://swe.quest/tags/jvm.md?difficulty=easy))

## Keywords

Buck2, Kotlin, Build Tools API, KSP2, jvm-abi-gen, kotlin-compiler-embeddable, jarjar

## Related posts

- [From Dagger to Metro](https://swe.quest/articles/from-dagger-to-metro-e5fb22ba684a3a3d.md): Vinted Engineering · 2026-02-12 · Medium · 6 min read · Mobile, Java & JVM, Refactoring & migrations, Build systems
  Vinted's Android team migrated a codebase of several hundred Gradle modules from Dagger, dagger.android and Anvil to Metro, a Kotlin compiler-plugin DI framework, mainly to escape Anvil's K1 lock-in and enable K2 and incremental compilation.
- [Build faster with Buck2: Our open source build system](https://swe.quest/articles/build-faster-with-buck2-our-open-source-build-system-ede49d4bb9123548.md): Meta Engineering · 2023-04-06 · Medium · 7 min read · Build systems, Rust, Open source, Developer productivity
  Buck2 is Meta's from-scratch rewrite of Buck, open sourced with a Rust core and all language rules written in Starlark, and it completes builds about twice as fast as Buck1 internally.
- [Extending Anvil for Fun and Profit](https://swe.quest/articles/extending-anvil-for-fun-and-profit-7f2a4cd8f637a17a.md): Slack Engineering · 2021-07-20 · Hard · 6 min read · Mobile, Java & JVM, Build systems, Compilers
  Slack's Android app replaced dagger-android activity injection with a custom Anvil code generator: annotating an activity with @InjectWith(scope) generates an AnvilInjector wrapping Dagger's intrinsic MembersInjector plus a @ContributesTo binding module that adds it to a scope-level multibinding map.
- [5 Things you didn’t know about Buck2](https://swe.quest/articles/5-things-you-didn-t-know-about-buck2-e7af8905ffa26190.md): Meta Engineering · 2023-10-23 · Easy · 3 min read · Build systems, Rust, Developer tools, Open source
  Buck2, Meta's open-source successor to the Buck build system, completes builds roughly 2x faster than Buck1 in internal tests.
- [From zero to 10 million lines of Kotlin](https://swe.quest/articles/from-zero-to-10-million-lines-of-kotlin-e0f9a5140a87605f.md): Meta Engineering · 2022-10-24 · Medium · 13 min read · Java & JVM, Refactoring & migrations, Mobile, Developer tools
  Meta has converted its Android codebase to over 10 million lines of Kotlin by wrapping JetBrains' J2K converter in an automated pipeline called Kotlinator.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
