freshcrate
Skin:/
Home > Uncategorized > kotlinpoet

kotlinpoet

A Kotlin API for generating .kt source files.

Why this rank:Strong adoptionRelease freshnessHealthy release cadence

Description

A Kotlin API for generating .kt source files.

README

KotlinPoet

KotlinPoet is a Kotlin and Java API for generating .kt source files.

License

Copyright 2017 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Release History

VersionChangesUrgencyDate
2.3.0Thanks to @haruue, @hfhbd, @yz4230, @mina-jaff, @BoD, @RaoPrashanth for contributing to this release. * New: Kotlin 2.3.20. * New: KSP 2.3.6. * New: Support for defining type aliases inside other types. (#2167) * New: Add `TypeName.annotated()` convenience API for adding annotations to types. (#2281) * New: Add `FileSpec.addImport(MemberName)` to explicitly import a member. (#2198) * New: Add `NameAllocator.contains` to check if a given tag is already allocated. (#2160) * New: `:interopMedium3/27/2026
2.2.0Thanks to @IRus for contributing to this release. * New: Kotlin 2.1.21. * New: KSP 2.1.21-2.0.1. * New: Add support for context parameters. (#2112) * New: Eliminate Guava dependency. (#2110) * New: Migrate to Dokka plugin V2. (#2113)Low5/16/2025
2.1.0Thanks to @ForteScarlet, @TrevorSStone, @RaoPrashanth, @damianw, @ansehoon1999, @TheMrMilchmann for contributing to this release. * New: Kotlin 2.1.10. * New: KSP 2.1.10-1.0.30. * Fix: Support delegates on anonymous classes. (#2034) * Fix: Prevent aliased imports from colliding with existing imports. (#2052) * Fix: `TypeName.MUTABLE_MAP_ENTRY` now correctly uses the `MutableEntry` nested class name. (#2061) * Fix: Use the same aliased import for both the nullable and non-nullable vLow2/25/2025
2.0.0Thanks to @brokenhappy, @tajobe, @niyajali, @ForteScarlet for contributing to this release. This release is source- and binary-compatible with KotlinPoet 1.x. The most important behavior change in this release is that spaces in generated code don't wrap by default anymore. KotlinPoet 1.x used to replace space characters with newline characters whenever a given line of code exceeded the length limit. This usually led to better code formatting, but could also lead to compilation errors inLow10/23/2024
1.18.1Thanks to @mitasov-ra for contributing to this release. - Fix: Workaround for [KT-18706](https://youtrack.jetbrains.com/issue/KT-18706): KotlinPoet now generates import aliases without backticks (#1920). ```kotlin // before, doesn't compile due to KT-18706 import com.example.one.`$Foo` as `One$Foo` import com.example.two.`$Foo` as `Two$Foo` // now, compiles import com.example.one.`$Foo` as One__Foo import com.example.two.`$Foo` as Two__Foo ```Low7/15/2024
1.18.0Thanks to @DanielGronau for contributing to this release. * New: Kotlin 2.0.0. * New: KSP 2.0.0-1.0.22. * New: Promote `kotlinpoet-metadata` out of preview to stable. * New: Migrate `kotlinpoet-metadata` to stable `org.jetbrains.kotlin:kotlin-metadata-jvm` artifact for Metadata parsing. * New: Make enum entry references in `KSAnnotation.toAnnotationSpec()` and `KSClassDeclaration.toClassName()` more robust. * Fix: Don't expand typealiases of function types to `LambdaTypeName`s in `Low7/5/2024
1.17.0Thanks to @jisungbin, @hfhbd, @evant, @sgjesse, @sebek64 for contributing to this release. - Change: kotlinx-metadata 0.9.0. Note that the `KotlinClassMetadata.read` is deprecated in 0.9.0 and replaced with `readStrict` (#1830). - Note: we now also provide `lenient` parameters to map to the underlying `readStrict()` and `readLenient()` calls (#1766). - We have also removed various `Class`/`TypeElement`/`Metadata`-to-`KmClass` APIs from the public API, as these are trivial to write now wLow5/24/2024
1.16.0Thanks to @drawers, @rickclephas for contributing to this release. - New: Kotlin 1.9.22. - New: KSP 1.9.22-1.0.16. - New: Add `NameAllocator` API to control keyword pre-allocation (#1803). - Fix: Fix issue with missing suspend modifier in `KSTypeReference.toTypeName` (#1793). - Fix: Honour same-package import aliases (#1794). - Fix: Always include parameter docs in the type header (#1800).Low1/18/2024
1.15.3Thanks to @gabrielittner for contributing to this release. * Fix: Fix nullability of lambdas in `KSTypeReference.toTypeName` (#1756).Low12/4/2023
1.15.2Thanks to @evant for contributing to this release. * New: Kotlin 1.9.21. * New: KSP 1.9.21-1.0.15. * New: KSP: more accurately represent function types (#1742).Low11/30/2023
1.15.1- Fix: Fix a regression introduced by #1637, where a superfluous newline is added to a type's KDoc if it has a primary constructor with no docs (#1727).Low11/19/2023
1.15.0Thanks to @drawers, @fejesjoco, @takahirom, @martinbonnin, @mcarleio for contributing to this release. In this release the `:kotlinpoet` module has been converted to a Kotlin Multiplatform module (#1654), though for now it only supports the JVM target. - New: Kotlin 1.9.20. - New: KSP 1.9.20-1.0.14. - New: Extract `TypeSpecHolder` interface for constructs that can hold a `TypeSpec` and their builders (#1723). - New: Expose relative path from `FileSpec` (#1720). - New: Return the generaLow11/18/2023
1.14.2* Fix: Fix one more missing API in binary compatibility override in `Annotatable.Builder` (#1581). Low5/30/2023
1.14.1* Fix: Restore ABI stability for annotatable and documentable builders (#1580).Low5/29/2023
1.14.0Thanks to [@Omico](https://github.com/Omico), [@drawers](https://github.com/drawers), [@RBusarow](https://github.com/RBusarow) for contributing to this release. * New: Kotlin 1.8.21. * New: KSP 1.8.21-1.0.11. * New: Enable default methods in Java bytecode (#1561). * New: Group Kotlin and Renovate updates together in Renovate (#1562). * New: Extract trait interface for annotatable constructs and their builders (#1564). * New: Extract trait interface for documentable constructs and tLow5/29/2023
1.13.2## What's Changed * KSType.toTypeName fixed to work with aliased types by @Squiry in https://github.com/square/kotlinpoet/pull/1534 ## New Contributors * @Squiry made their first contribution in https://github.com/square/kotlinpoet/pull/1534 **Full Changelog**: https://github.com/square/kotlinpoet/compare/1.13.1...1.13.2Low5/5/2023
1.13.1## What's Changed * Fix: Look at canonical names instead of just package names when generating import aliases by @Egorand in https://github.com/square/kotlinpoet/pull/1519 * Fix: Ignore KSP annotation arguments without a value by @rickclephas in https://github.com/square/kotlinpoet/pull/1523 * Fix: Fix arguments handling in KSType.toTypeName() by @ZacSweers in https://github.com/square/kotlinpoet/pull/1529 ## New Contributors * @rickclephas made their first contribution in https://githuLow4/28/2023
1.13.0## What's Changed * New: Kotlin 1.8.0. * New: KSP 1.8.0-1.0.9. * New: Support context receivers on TypeSpecs + extract ContextReceivable API (#1269). * New: Optimize `OriginatingElements` and `TagMap` implementations (#1270). * New: Auto-generate import aliases for types and members (#1355). * New: Insert underscores into large decimal literals (#1384). * New: New factory function `FileSpec.builder(ClassName)` (#1397). * Fix: Fix StackOverflowError when calling `KSTypeArgument.toTypeNameLow4/6/2023
1.12.0## What's Changed * Fix typo in changelog by @WhosNickDoglio in https://github.com/square/kotlinpoet/pull/1228 * Fix doc site list by @ZacSweers in https://github.com/square/kotlinpoet/pull/1231 * Add Java 18 to CI build matrix by @Egorand in https://github.com/square/kotlinpoet/pull/1237 * Run tests on all JDKs but only build on 18 by @Egorand in https://github.com/square/kotlinpoet/pull/1238 * setup-java v3 by @sullis in https://github.com/square/kotlinpoet/pull/1239 * Add support for coLow6/13/2022
1.11.0Thanks to [@liujingxing](https://github.com/liujingxing) and [@BoD](https://github.com/BoD) for contributing to this release. * New: Kotlin scripting support in `FileSpec`. ```kotlin val spec = FileSpec.scriptBuilder("Taco") .addStatement("println(%S)", "hello world!") .addKotlinDefaultImports() .build() ``` Generates a Taco.kts file with the following contents: ```kotlin println("hello world!") ``` * New: Emit trailing commas for multi-line parameLow3/24/2022
1.10.2Thanks to [@glureau](https://github.com/glureau) and [@goooler](https://github.com/goooler) for contributing to this release. * [#1175] New: Switch `AnnotationSpec.get()` to use the `arrayOf()` syntax instead of `[]`. * [#1170] Fix: Don't wrap aliasing imports with long package names. * [#1174] Fix: Don't wrap type names inside line comments. * [#1167] Fix: Ignore Java's `@Deprecated` annotations on synthetic methods for annotations. Low10/22/2021
1.10.1Thanks to [@evant](https://github.com/evant) for contributing to this release. * Fix: Correct generation of typealiases with type args in KSP interop. * Fix: Add missing default `TypeParameterResolver.EMPTY` argument to `fun KSTypeArgument.toTypeName` in KSP interop.Low9/21/2021
1.10.0Thanks to [@martinbonnin](https://github.com/martinbonnin), [@idanakav](https://github.com/idanakav), [@goooler](https://github.com/goooler), and [@anandwana001](https://github.com/anandwana001) for contributing to this release. * New: Add a new [KSP](https://github.com/google/ksp) interop artifact. See [docs](https://square.github.io/kotlinpoet/interop-ksp/) for more details. * New: Add a new [JavaPoet](https://github.com/square/javapoet) interop artifact. See [docs](https://square.githubLow9/20/2021
1.9.0- New: Kotlin 1.5.10. - New: Previously deprecated API to interop with Java reflection and Mirror API have been un-deprecated and marked with `@DelicateKotlinPoetApi` annotation. - New: `CodeBlock.Builder.withIndent` helper function. - New: Allow changing initializers and default values in `ParameterSpec.Builder` and `PropertySpec.Builder` after they were set. - New: `MemberName.isExtension` property that instructs KotlinPoet to always import the member, even if conflicting declarations are Low6/22/2021

Dependencies & License Audit

Loading dependencies...

Similar Packages

fabriktGenerates Kotlin Code from OpenAPI 3 Specifications27.1.0
kotlinx-schemaKotlin Multiplatform library that generates JSON Schemas from your methods and classes both at compile-time via Kotlin Symbol Processing(KSP) and at runtime via reflection or kotlinx.serialization.v0.5.0
slot-jsx-pragma🎰 Enable declarative slottable components with a custom JSX pragma for seamless React integration and enhanced performance.main@2026-06-06
alefGenerate fully-typed, lint-clean language bindings for Rust libraries across 11 languagesv0.23.18
local-ai-devenv🤖 Automate coding, testing, and deployment with a local AI environment powered by a team of intelligent agents.main@2026-06-06

More from square

square-mcp-serverA Model Context Protocol (MCP) server for square

More in Uncategorized

llama.cppLLM inference in C/C++
modal-clientSDK libraries for Modal
anolisaANOLISA - Agentic Nexus Operating Layer & Interface System Architecture