Java/Kotlin ABIs
This topic pertains to building Java code with Buck2.
When compiling a Kotlin or Java rule, Buck2 creates an Application Binary Interface (ABI) JAR, which contains only resources and class interfaces—the public interface for your module. Buck2 creates this ABI JAR in addition to the library JAR, which contains all of the compiled classes and resources for the rule.
Since ABI JARs do not contain method bodies or private members, they are smaller and change less frequently than library JARs. This enables Buck2 to use ABI JARs in two important ways:
-
Incremental builds - ABI JARs help Buck2 more accurately determine which rules need to be rebuilt during an incremental build. A Java/Kotlin library rule does not necessarily need to be rebuilt if one of its dependencies changes, provided that the public interface of that dependency did not change. This knowledge helps avoid unnecessary rebuilds.
-
Compilation performance - ABI JARs can be used on the compiler's classpath instead of library JARs. The smaller size of ABI JARs enables the compiler to load them faster than library JARs, providing a performance boost.