Releases: square/kotlinpoet
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 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)
1.18.1
Thanks to @mitasov-ra for contributing to this release.
// 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
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 stableorg.jetbrains.kotlin:kotlin-metadata-jvm
artifact for Metadata parsing. - New: Make enum entry references in
KSAnnotation.toAnnotationSpec()
andKSClassDeclaration.toClassName()
more robust. - Fix: Don't expand typealiases of function types to
LambdaTypeName
s inKSTypeReference.toTypeName()
. - Fix: Avoid rounding small double and float values in
%L
translation (#1927). - Fix: Fix typealias type argument resolution in KSP2 (#1929).
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 withreadStrict
(#1830).- Note: we now also provide
lenient
parameters to map to the underlyingreadStrict()
andreadLenient()
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).
- Note: we now also provide
- New: Supertype list wraps to one-per-line if the primary constructor spans multiple lines (#1866).
- New: Extract
MemberSpecHolder
interface for constructs that can holdPropertySpec
s andFunSpec
s and their builders (#1877). - New:
joinToCode
variant which operates on any type, but requires a transform lambda to convert each element into aCodeBlock
(#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:
MemberName
s 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
MemberName
s (#1909).
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).
1.15.3
1.15.2
1.15.1
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 aTypeSpec
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()
andTypeSpec.valueClassBuilder()
(#1589). - New: Add option to convert
KSAnnotation
toAnnotationSpec
while omitting default values (#1538). - New: Add
FileSpec.builder
convenience forMemberName
(#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 mostFlags
-API extensions have been removed in favor of the now-available first-party versions.