Skip to content

Update kotlinpoet to v2 - #7105

Closed
renovate[bot] wants to merge 2 commits into
mainfrom
renovate/major-kotlinpoet
Closed

Update kotlinpoet to v2#7105
renovate[bot] wants to merge 2 commits into
mainfrom
renovate/major-kotlinpoet

Conversation

@renovate

@renovate renovate Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Change Age Confidence
com.squareup:kotlinpoet-ksp 1.11.02.3.0 age confidence
com.squareup:kotlinpoet 1.11.02.3.0 age confidence

Release Notes

square/kotlinpoet (com.squareup:kotlinpoet-ksp)

v2.3.0

Compare Source

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:javapoet module has been discontinued and is not published starting with this release. (#​2292)
  • New: In-development snapshots are now published to the Central Portal Snapshots repository at https://central.sonatype.com/repository/maven-snapshots/. (#​2135)
  • Fix: Annotation array parameters with annotation elements now correctly handled. (#​2142)
  • Fix: KType.asTypeName now correctly handles recursively bound generics (e.g. T : Comparable<T>). (#​2162)
  • Fix: Don't convert multi-statement function to expression body. (#​2163)
  • Fix: FunSpec.beginControlFlow now accepts nullable arguments for consistency with CodeBlock.beginControlFlow. (#​2174)
  • Fix: Ignore illegal characters inside escaped identifiers. (#​2204)
  • Fix: emitNullable correctly when deferring type in CodeWriter. (#​2217)
  • Fix: Escape /* and */ when emitting Kdoc. (#​2258)
  • Fix: Generate imports for extension members used via %M in KDocs. (#​2266)

v2.2.0

Compare Source

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)

v2.1.0

Compare Source

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 versions of a type. (#​2068)
  • Fix: Allow zero methods in a functional interface if it has a superinterface. (#​2075)

v2.0.0

Compare Source

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 generated code. Non-breaking spaces could be marked by the · character, but the discoverability of this feature wasn't great.

KotlinPoet 2.0 does not wrap spaces, even if the line of code they occur in exceeds the length limit. The newly introduced character can be used to mark spaces that are safe to wrap, which can improve code formatting. The · character has been preserved for compatibility, but its behavior is now equivalent to a regular space character.

  • New: Kotlin 2.0.10.
  • New: Spaces don't break by default.
  • New: New placeholder representing a space that is safe to wrap.
  • New: Add KSTypeAlias.toClassName(). (#​1956)
  • New: Add KSType.toClassNameOrNull(). (#​1956)
  • Fix: Enum classes that only have an init block now also generate the required semicolon. (#​1953)
  • Fix: Preserve typealiases in KSAnnotation.toAnnotationSpec(). (#​1956)
  • Fix: Preserve nullability in KSType.toClassName(). (#​1956)

v1.18.1

Compare Source

Thanks to @​mitasov-ra for contributing to this release.

  • Fix: Workaround for KT-18706: KotlinPoet now generates import aliases without backticks (#​1920).
// 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

v1.18.0

Compare Source

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 LambdaTypeNames in KSTypeReference.toTypeName().
  • Fix: Avoid rounding small double and float values in %L translation (#​1927).
  • Fix: Fix typealias type argument resolution in KSP2 (#​1929).

v1.17.0

Compare Source

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 with kotlinx-metadata's newer APIs and allows us to focus the API surface area of this artifact better (#​1891).
  • New: Supertype list wraps to one-per-line if the primary constructor spans multiple lines (#​1866).
  • New: Extract MemberSpecHolder interface for constructs that can hold PropertySpecs and FunSpecs and their builders (#​1877).
  • New: joinToCode variant which operates on any type, but requires a transform lambda to convert each element into a CodeBlock (#​1874).
  • New: Support annotation type arguments in KSAnnotation.toAnnotationSpec() (#​1889).
  • Fix: Prevent name clashes between a function in class and a function call in current scope (#​1850).
  • Fix: Fix extension function imports (#​1814).
  • Fix: Omit implicit modifiers on FileSpec.scriptBuilder (#​1813).
  • Fix: Fix trailing newline in PropertySpec (#​1827).
  • Fix: KSAnnotation.toAnnotationSpec writes varargs in place instead of making them an array to work around a Kotlin issue with OptIn annotations (#​1833).
  • Fix: MemberNames without a package are now correctly imported (#​1841)
  • Fix: Throw if primary constructor delegates to other constructors (#​1859).
  • Fix: Aliased imports with nested class (#​1876).
  • Fix: Check for error types in KSType.toClassName() (#​1890).
  • Fix: Support generating a single import for overloaded MemberNames (#​1909).

v1.16.0

Compare Source

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).

v1.15.3

Compare Source

Thanks to @​gabrielittner for contributing to this release.

  • Fix: Fix nullability of lambdas in KSTypeReference.toTypeName (#​1756).

v1.15.2

Compare Source

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).

v1.15.1

Compare Source

  • 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).

v1.15.0

Compare Source

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 generated path from FileSpec.writeTo(). (#​1514).
  • New: Remove default compatibility from unstable types (#​1662).
  • New: Deprecate TypeSpec.expectClassBuilder() and TypeSpec.valueClassBuilder() (#​1589).
  • New: Add option to convert KSAnnotation to AnnotationSpec while omitting default values (#​1538).
  • New: Add FileSpec.builder convenience for MemberName (#​1585).
  • Fix: Set DecimalFormatSymbols.minusSign for consistency across locales (#​1658).
  • Fix: Fix link to incremental KSP in KDoc (#​1638).
  • Fix: Emit primary constructor KDoc (#​1637).
  • Change: kotlinx-metadata 0.7.0. This is a breaking change for users of the :kotlinpoet-metadata module, as most Flags-API extensions have been removed in favor of the now-available first-party versions.

v1.14.2

Compare Source

  • Fix: Fix one more missing API in binary compatibility override in Annotatable.Builder (#​1581).

v1.14.1

Compare Source

  • Fix: Restore ABI stability for annotatable and documentable builders (#​1580).

v1.14.0

Compare Source

Thanks to @​Omico, @​drawers, @​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 their builders (#​1571).

  • New: Document the usage of STAR (#​1572).

  • New: Add builder for FunSpec which accepts a MemberName (#​1574).

  • Fix: Omit public modifier on override function or constructor parameters (#​1550).

  • Fix: Correct handling of members in various types (#​1558).

  • Fix: Function return types now default to Unit unless explicitly set (#​1559).

    Previously the default was null which behaved like Unit for block bodies. When an expression body was produced,
    however, no return type would be emitted. This meant that the return type was implicit based on the contents of
    the body.

    With this change, when no return type is specified and an expression body is produced, the return type will be
    explicitly Unit. Specify the actual return type explicitly to correct the output.

    Old versions:

    val funSpec = FunSpec.builder("foo")
      .addStatement("return 1")
      .build()
    public fun foo() = 1

    This version, incorrect:

    val funSpec = FunSpec.builder("foo")
      .addStatement("return 1")
      .build()
    public fun foo(): Unit = 1 //

    This version, correct:

     val funSpec = FunSpec.builder("foo")
    +  .returns(INT)
       .addStatement("return 1")
       .build()
    public fun foo(): Int = 1 //

    Additionally, as part of this change, FunSpec.returnType has changed to be non-nullable. This is a source- and
    binary-compatible change, although if you were performing null-checks then new warnings may appear after upgrade.

  • Fix: Append nested class names to alias during name lookup (#​1568).

  • Fix: Allow PropertySpec with context receivers and without getter or setter (#​1575).

v1.13.2

Compare Source

What's Changed
New Contributors

Full Changelog: square/kotlinpoet@1.13.1...1.13.2

v1.13.1

Compare Source

What's Changed
New Contributors

Full Changelog: square/kotlinpoet@1.13.0...1.13.1

v1.13.0

Compare Source

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() for a wildcard in a recursive type bound (#​1272).
  • Fix: Fix transitive aliases (#​1306).
  • Fix: Fix Aliases as TypeArgument (#​1321).
  • Fix: Don't escape special characters inside raw strings (#​1331).
  • Fix: Fix KSP interop's output of the annotation parameter value of type Char (#​1338).
  • Fix: Fix KSP interop's output for primitive arrays (#​1340).
  • Fix: Avoid emitting public if shouldEmitPublicModifier returns false (#​1342).
  • Fix: Fix context receivers being rendered in an incorrect position when on a nullable/suspending LambdaTypeName (#​1454).
  • Fix: Do not use bestGuess for KClass.asClassName (#​1469).
  • Fix: Handle fake nested types with platform mapped parents (#​1472).
  • Fix: Fix TypeName equals (#​1477).
  • Fix: Make equals consistent with compareTo for ClassName (#​1506).
New Contributors

Full Changelog: square/kotlinpoet@1.12.0...1.13.0

v1.12.0

Compare Source

What's Changed
New Contributors

Full Changelog: square/kotlinpoet@1.11.0...1.12.0


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about these updates again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

Copilot AI review requested due to automatic review settings June 29, 2026 17:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot can't review bot-authored pull requests automatically. A user with Copilot access can request a review manually.

@jpelgrom jpelgrom mentioned this pull request Jun 29, 2026
1 task
@jpelgrom

Copy link
Copy Markdown
Member

Closing because of the comment with the reason why we pinned to 1.11.0, the required PR is not yet in a release.

1.11.0 is the last version that works, we can bump it once square/kotlinpoet#2320 is merged [in a release]

@jpelgrom jpelgrom closed this Jun 29, 2026
@renovate

renovate Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Renovate Ignore Notification

Because you closed this PR without merging, Renovate will ignore this update. You will not get PRs for any future 2.x releases. But if you manually upgrade to 2.x then Renovate will re-enable minor and patch updates automatically.

If you accidentally closed this PR, or if you changed your mind: rename this PR to get a fresh replacement PR.

@renovate
renovate Bot deleted the renovate/major-kotlinpoet branch June 29, 2026 17:23
@jpelgrom

Copy link
Copy Markdown
Member

@TimoPtr We'll need to monitor releases ourselves for a bit here, as it is a major version update we cannot ignore only 2.3.0 it seems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants