Repolode
square

square/kotlinpoet

A Kotlin and Java API for programmatically generating Kotlin .kt source files.

Stars
4,164
Forks
318
Open issues
68
Last commit
4 days ago

What is it?

KotlinPoet is a library that lets developers build Kotlin source files from code instead of writing text templates by hand. It is usable from both Kotlin and Java, and it is the Kotlin counterpart to JavaPoet, which serves the same purpose for Java.

The library is aimed at annotation processors, build plugins and other code generators that need to emit correct Kotlin code. Generated output is produced through a builder-style API that handles the bookkeeping of types, imports and formatting for the caller.

The project is maintained by Square and published under the Apache-2.0 license, with documentation hosted on its project site.

Key features

  • 01Generates .kt source files from a programmatic, builder-style API.
  • 02Can be called from both Kotlin and Java code.
  • 03Handles type references and import statements in generated output.
  • 04Serves as the Kotlin counterpart to JavaPoet.

Use cases

  • Writing annotation processors that emit Kotlin classes or functions.
  • Building Gradle or Maven plugins that generate Kotlin boilerplate.
  • Producing Kotlin code from schemas or other metadata at build time.

Quick start

  1. 1

    Visit the project documentation at the official site

Things to know

  • The README is minimal and gives no installation command or usage example.

Topics

#code-generation#kotlin#java#annotation-processing#javapoet#build-tools

FAQ

What is kotlinpoet?
A Kotlin and Java API for programmatically generating Kotlin .kt source files. KotlinPoet is a library that lets developers build Kotlin source files from code instead of writing text templates by hand. It is usable from both Kotlin and Java, and it is the Kotlin counterpart to JavaPoet, which serves the same purpose for Java.
Is kotlinpoet free to use? What license does it have?
kotlinpoet is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is kotlinpoet still maintained?
Actively maintained. The last commit to kotlinpoet was on Nov 2, 2026.
What can I use kotlinpoet for?
Writing annotation processors that emit Kotlin classes or functions. Building Gradle or Maven plugins that generate Kotlin boilerplate. Producing Kotlin code from schemas or other metadata at build time.
How do I install kotlinpoet?
Visit the project documentation at the official site
Where can I get kotlinpoet?
The source code and installation instructions are on GitHub: https://github.com/square/kotlinpoet

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects