| 2.3.0 | Thanks 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: `:interop | Medium | 3/27/2026 |
| 2.2.0 | Thanks 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) | Low | 5/16/2025 |
| 2.1.0 | Thanks 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 v | Low | 2/25/2025 |
| 2.0.0 | Thanks 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 in | Low | 10/23/2024 |
| 1.18.1 | Thanks 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 ``` | Low | 7/15/2024 |
| 1.18.0 | Thanks 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 ` | Low | 7/5/2024 |
| 1.17.0 | Thanks 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 w | Low | 5/24/2024 |
| 1.16.0 | Thanks 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). | Low | 1/18/2024 |
| 1.15.3 | Thanks to @gabrielittner for contributing to this release. * Fix: Fix nullability of lambdas in `KSTypeReference.toTypeName` (#1756). | Low | 12/4/2023 |
| 1.15.2 | Thanks 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). | Low | 11/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). | Low | 11/19/2023 |
| 1.15.0 | Thanks 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 genera | Low | 11/18/2023 |
| 1.14.2 | * Fix: Fix one more missing API in binary compatibility override in `Annotatable.Builder` (#1581). | Low | 5/30/2023 |
| 1.14.1 | * Fix: Restore ABI stability for annotatable and documentable builders (#1580). | Low | 5/29/2023 |
| 1.14.0 | Thanks 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 t | Low | 5/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.2 | Low | 5/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://githu | Low | 4/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.toTypeName | Low | 4/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 co | Low | 6/13/2022 |
| 1.11.0 | Thanks 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 parame | Low | 3/24/2022 |
| 1.10.2 | Thanks 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. | Low | 10/22/2021 |
| 1.10.1 | Thanks 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. | Low | 9/21/2021 |
| 1.10.0 | Thanks 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.github | Low | 9/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 | Low | 6/22/2021 |