From 8cdf7fd5af0f265286d539dea3a3badd0467187e Mon Sep 17 00:00:00 2001 From: Drew Hamilton Date: Fri, 13 Dec 2024 21:13:56 -0600 Subject: [PATCH] Release 0.18.1 --- CHANGELOG.md | 16 ++++++++++++++++ README.md | 48 +++++++++++++++++++++++++++++++---------------- gradle.properties | 2 +- 3 files changed, 49 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9d3f545..0864fdbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## 0.18.1 +_2024-12-13 + +Add ability to skip individual properties with `@Poko.Skip`. These properties will be omitted from +all generated functions. This feature is experimental and requires opt-in via `@SkipSupport`. + +Replace `@ArrayContentBased` with `@Poko.ReadArrayContent`. Add a deprecated `typealias` for the +former to aid migration. + +Add support for use optional property-level features with custom Poko annotation. Nested annotations +with the same name as the optional feature, such as `@MyData.ReadArrayContent` and +`@MyData.Skip`, will be respected. + +Fix issue with FIR checkers. K2-enabled IDEs should now highlight Poko errors and warnings in +consumer source code. + ## 0.18.0 _2024-12-2_ diff --git a/README.md b/README.md index 63f207a7..afa40ec4 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,26 @@ generate that function but will still generate the non-overridden functions. Usi is not recommended, and if they are used, it is recommended to override `equals` and `hashCode` manually. +### Annotation +By default, the `dev.drewhamilton.poko.Poko` annotation is used to mark classes for Poko generation. +If you prefer, you can create a different annotation and supply it to the Gradle plugin. + +```groovy +apply plugin: "dev.drewhamilton.poko" +poko { + pokoAnnotation.set "com/example/MyData" +} +``` + +Nested annotations mentioned below can optionally be added with the same name to the base annotation +and used for their respective features. For example, `@MyData.ReadArrayContent` will cause the +annotated property's contents to be used in the Poko-generated functions. + ### Arrays By default, Poko does nothing to inspect the contents of array properties. [This aligns with the behavior of data classes](https://blog.jetbrains.com/kotlin/2015/09/feedback-request-limitations-on-data-classes/#Appendix.Comparingarrays). -Poko consumers can change this behavior on a per-property basis with the `@ArrayContentBased` +Poko consumers can change this behavior on a per-property basis with the `@Poko.ReadArrayContent` annotation. On properties of a typed array type, this annotation will generate a `contentDeepEquals` check. On properties of a primitive array type, this annotation will generate a `contentEquals` check. And on properties of type `Any` or of a generic type, this annotation will generate a `when` @@ -39,24 +54,25 @@ statement that disambiguates the many array types at runtime and uses the approp `contentDeepEquals` or `contentEquals` check. In all cases, the corresponding content-based `hashCode` and `toString` are generated for the property as well. -Using arrays as properties in data types is still not generally recommended: arrays are mutable, and +Using arrays as properties in data types is not generally recommended: arrays are mutable, and mutating data can affect the results of `equals` and `hashCode` over time, which is generally -unexpected. For this reason, `@ArrayContentBased` should only be used in very performance-sensitive -APIs. +unexpected. For this reason, `@Poko.ReadArrayContent` should only be used in very +performance-sensitive APIs. -### Annotation -By default, the `dev.drewhamilton.poko.Poko` annotation is used to mark classes for Poko generation. -If you prefer, you can create a different annotation and supply it to the Gradle plugin. +### Skipping properties -```groovy -apply plugin: "dev.drewhamilton.poko" -poko { - pokoAnnotation.set "com/example/MyDataAnnotation" -} -``` +It is sometimes useful to omit some properties from consideration when generating the Poko +functions. This can be done with the experimental `@Poko.Skip` annotation. Properties with this +annotation will be excluded from all three generated functions. For example: -Note that this only affects the primary marker annotation. Supplemental annotations such as -`@ArrayContentBased` do not support customization. +```kotlin +@Poko class Data( + val id: String, + @Poko.Skip val callback: () -> Unit, +) : CircuitUiState + +Data("a", { println("a") }) == Data("a", { println("not a") }) // yields `true` +``` ### Download @@ -71,7 +87,7 @@ exclusively compatible with specific versions of Poko. | Kotlin version | Poko version | |-----------------|--------------| -| 2.1.0 | 0.18.0 | +| 2.1.0 | 0.18.1 | | 2.0.0 – 2.0.21 | 0.17.2 | | 1.9.0 – 1.9.24 | 0.15.3 | | 1.8.20 – 1.8.22 | 0.13.1 | diff --git a/gradle.properties b/gradle.properties index 215a9bc6..c0f7aa2c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ kotlin.code.style=official kotlin.js.stdlib.dom.api.included=false PUBLISH_GROUP=dev.drewhamilton.poko -PUBLISH_VERSION=0.19.0-SNAPSHOT +PUBLISH_VERSION=0.18.1 # Uncomment to enable snapshot dependencies: #snapshots_repository=https://oss.sonatype.org/content/repositories/snapshots