Generate repetitive Java boilerplate classes automatically using annotation processing instead of hand-writing them.
Build a code generation tool that produces readable, well-formatted Java source files programmers can inspect and verify.
Replace error-prone string concatenation in code generators with JavaPoet's type-safe builder API.
Project is officially deprecated since October 2020, use the Palantir fork for new Java language feature support.
JavaPoet is a Java library that lets you write programs that generate other Java programs. Instead of manually typing out repetitive Java code, you write Java code that describes what you want to produce, and JavaPoet assembles the final source file for you. This is useful in situations like annotation processing, where tools need to create helper classes automatically based on your project's structure. The library gives you building blocks for every part of a Java file: classes, interfaces, methods, constructors, fields, parameters, and annotations. You assemble these pieces with a builder-style API, then ask JavaPoet to render everything into a properly formatted .java file. It handles indentation, semicolons, import statements, and other formatting details so you do not have to. A small but important note: Square officially deprecated this project in October 2020. They no longer maintain it. The README points to a fork maintained by Palantir as an alternative for anyone who needs support for newer Java language features. Switching requires updating your build coordinates and running a short find-and-replace on your import statements. Before deprecation, the library had wide adoption for code generation tasks in Android and Java projects. The core concepts are straightforward: you describe a method or class in Java, and JavaPoet serializes that description into valid source text you can inspect, test, or write to disk. Because it produces readable source code rather than compiled bytecode, you can open the output files and verify they look exactly as intended. The README is detailed and covers the full API including type references, generics, annotations, Javadoc comments, and anonymous inner classes, with code examples for each feature.
← square on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.