├── .github
└── workflows
│ ├── ci.yml
│ └── release.yml
├── .gitignore
├── .idea
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── kotlinCodeInsightSettings.xml
├── kotlinc.xml
├── libraries-with-intellij-classes.xml
└── vcs.xml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── RELEASING.md
├── build-support
├── build.gradle.kts
├── settings.gradle.kts
└── src
│ └── main
│ └── java
│ └── dev
│ └── drewhamilton
│ └── poko
│ └── build
│ ├── PokoBuildExtension.kt
│ ├── PokoBuildPlugin.kt
│ ├── PokoSettingsPlugin.kt
│ └── publish.kt
├── build.gradle.kts
├── gradle.properties
├── gradle
├── libs.versions.toml
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── kotlin-js-store
└── yarn.lock
├── poko-annotations
├── api
│ └── poko-annotations.api
├── build.gradle.kts
└── src
│ └── commonMain
│ └── kotlin
│ └── dev
│ └── drewhamilton
│ └── poko
│ ├── ArrayContentBased.kt
│ ├── Poko.kt
│ └── optInAnnotations.kt
├── poko-compiler-plugin
├── api
│ └── poko-compiler-plugin.api
├── build.gradle.kts
├── gradle.properties
└── src
│ ├── main
│ └── kotlin
│ │ └── dev
│ │ └── drewhamilton
│ │ └── poko
│ │ ├── CompilerOptions.kt
│ │ ├── PokoAnnotationNames.kt
│ │ ├── PokoCommandLineProcessor.kt
│ │ ├── PokoCompilerPluginRegistrar.kt
│ │ ├── PokoFunction.kt
│ │ ├── fir
│ │ ├── PokoFirCheckersExtension.kt
│ │ ├── PokoFirDeclarationGenerationExtension.kt
│ │ ├── PokoFirExtensionRegistrar.kt
│ │ ├── PokoFirExtensionSessionComponent.kt
│ │ └── PokoKey.kt
│ │ └── ir
│ │ ├── PokoFunctionBodyFiller.kt
│ │ ├── PokoIrGenerationExtension.kt
│ │ ├── PokoMembersTransformer.kt
│ │ ├── PokoOrigin.kt
│ │ ├── compat.kt
│ │ ├── equalsGeneration.kt
│ │ ├── functionGeneration.kt
│ │ ├── hashCodeGeneration.kt
│ │ ├── irHelpers.kt
│ │ ├── logging.kt
│ │ └── toStringGeneration.kt
│ └── test
│ ├── kotlin
│ └── dev
│ │ └── drewhamilton
│ │ └── poko
│ │ └── PokoCompilerPluginTest.kt
│ └── resources
│ ├── api
│ ├── DataInterface.kt
│ ├── MultipleInterface.kt
│ └── Primitives.kt
│ └── illegal
│ ├── Data.kt
│ ├── GenericArrayHolder.kt
│ ├── Interface.kt
│ ├── NoConstructorProperties.kt
│ ├── NoPrimaryConstructor.kt
│ ├── NotArrayHolder.kt
│ ├── OuterClass.kt
│ └── Value.kt
├── poko-gradle-plugin
├── api
│ └── poko-gradle-plugin.api
├── build.gradle.kts
└── src
│ └── main
│ └── kotlin
│ └── dev
│ └── drewhamilton
│ └── poko
│ └── gradle
│ ├── PokoGradlePlugin.kt
│ └── PokoPluginExtension.kt
├── poko-tests
├── build.gradle.kts
├── performance
│ ├── build.gradle.kts
│ └── src
│ │ └── test
│ │ └── kotlin
│ │ ├── JsPerformanceTest.kt
│ │ ├── JvmPerformanceTest.kt
│ │ ├── asm.kt
│ │ └── sources.kt
└── src
│ ├── commonMain
│ └── kotlin
│ │ ├── Super.kt
│ │ ├── data
│ │ ├── AnyArrayHolder.kt
│ │ ├── Complex.kt
│ │ ├── ExplicitDeclarations.kt
│ │ ├── Nested.kt
│ │ ├── Simple.kt
│ │ └── SuperclassDeclarations.kt
│ │ ├── performance
│ │ ├── IntAndLong.kt
│ │ ├── Main.kt
│ │ └── UIntAndLong.kt
│ │ └── poko
│ │ ├── AnyArrayHolder.kt
│ │ ├── ArrayHolder.kt
│ │ ├── Complex.kt
│ │ ├── ComplexGenericArrayHolder.kt
│ │ ├── Expected.kt
│ │ ├── ExplicitDeclarations.kt
│ │ ├── GenericArrayHolder.kt
│ │ ├── Nested.kt
│ │ ├── Simple.kt
│ │ ├── SimpleWithExtraParam.kt
│ │ ├── SkippedProperty.kt
│ │ ├── SuperclassDeclarations.kt
│ │ └── SuperclassWithFinalOverrides.kt
│ ├── commonTest
│ └── kotlin
│ │ ├── AnyArrayHolderTest.kt
│ │ ├── ArrayHolderTest.kt
│ │ ├── ComplexGenericArrayHolderTest.kt
│ │ ├── ComplexTest.kt
│ │ ├── ExpectedTest.kt
│ │ ├── ExplicitDeclarationsTest.kt
│ │ ├── GenericArrayHolderTest.kt
│ │ ├── NestedTest.kt
│ │ ├── SimpleTest.kt
│ │ ├── SimpleWithExtraParamTest.kt
│ │ ├── SkippedPropertyTest.kt
│ │ ├── SuperclassDeclarationsTest.kt
│ │ └── SuperclassWithFinalOverridesTest.kt
│ ├── jsMain
│ └── kotlin
│ │ └── poko
│ │ └── Expected.js.kt
│ ├── jvmMain
│ └── kotlin
│ │ └── poko
│ │ └── Expected.jvm.kt
│ ├── nativeMain
│ └── kotlin
│ │ └── poko
│ │ └── Expected.native.kt
│ ├── wasmJsMain
│ └── kotlin
│ │ └── poko
│ │ └── Expected.wasmJs.kt
│ └── wasmWasiMain
│ └── kotlin
│ └── poko
│ └── Expected.wasmWasi.kt
├── renovate.json5
├── sample
├── build.gradle.kts
├── buildSrc
│ ├── build.gradle.kts
│ ├── settings.gradle.kts
│ └── src
│ │ └── main
│ │ └── kotlin
│ │ └── dev
│ │ └── drewhamilton
│ │ └── poko
│ │ └── sample
│ │ └── build
│ │ └── java.kt
├── compose
│ ├── build.gradle.kts
│ └── src
│ │ ├── main
│ │ └── kotlin
│ │ │ └── dev
│ │ │ └── drewhamilton
│ │ │ └── poko
│ │ │ └── sample
│ │ │ └── compose
│ │ │ ├── Poko.kt
│ │ │ └── Sample.kt
│ │ └── test
│ │ └── kotlin
│ │ └── dev
│ │ └── drewhamilton
│ │ └── poko
│ │ └── sample
│ │ └── compose
│ │ └── SampleTest.kt
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── jvm
│ ├── build.gradle.kts
│ └── src
│ │ ├── main
│ │ └── kotlin
│ │ │ └── dev
│ │ │ └── drewhamilton
│ │ │ └── poko
│ │ │ └── sample
│ │ │ └── jvm
│ │ │ ├── MyData.kt
│ │ │ └── Sample.kt
│ │ ├── test
│ │ └── kotlin
│ │ │ └── dev
│ │ │ └── drewhamilton
│ │ │ └── poko
│ │ │ └── sample
│ │ │ └── jvm
│ │ │ └── SampleTest.kt
│ │ └── testFixtures
│ │ └── kotlin
│ │ └── dev
│ │ └── drewhamilton
│ │ └── poko
│ │ └── sample
│ │ └── jvm
│ │ └── SampleFixture.kt
├── kotlin-js-store
│ └── yarn.lock
├── mpp
│ ├── build.gradle.kts
│ └── src
│ │ ├── commonMain
│ │ └── kotlin
│ │ │ └── dev
│ │ │ └── drewhamilton
│ │ │ └── poko
│ │ │ └── sample
│ │ │ └── mpp
│ │ │ ├── ArraysSample.kt
│ │ │ └── Sample.kt
│ │ └── commonTest
│ │ └── kotlin
│ │ └── dev
│ │ └── drewhamilton
│ │ └── poko
│ │ └── sample
│ │ └── mpp
│ │ ├── ArraysSampleTest.kt
│ │ └── SampleTest.kt
├── properties.gradle
└── settings.gradle.kts
└── settings.gradle.kts
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 | pull_request:
7 |
8 | jobs:
9 | build:
10 | runs-on: macos-latest
11 | steps:
12 | - name: Check out the repo
13 | uses: actions/checkout@v4
14 | - name: Install JDK
15 | uses: actions/setup-java@v4
16 | with:
17 | distribution: zulu
18 | java-version: 23
19 |
20 | - name: Set up Gradle
21 | uses: gradle/actions/setup-gradle@v4
22 |
23 | - name: Build
24 | run: >-
25 | ./gradlew
26 | :poko-annotations:build
27 | :poko-compiler-plugin:build
28 | :poko-gradle-plugin:build
29 | publishToMavenLocal
30 | --stacktrace
31 | env:
32 | ORG_GRADLE_PROJECT_personalGpgKey: ${{ secrets.ORG_GRADLE_PROJECT_personalGpgKey }}
33 | ORG_GRADLE_PROJECT_personalGpgPassword: ${{ secrets.ORG_GRADLE_PROJECT_personalGpgPassword }}
34 |
35 | - name: Upload MavenLocal directory
36 | uses: actions/upload-artifact@v4
37 | with:
38 | name: MavenLocal
39 | path: ~/.m2/repository/dev/drewhamilton/poko/
40 | if-no-files-found: error
41 |
42 | - name: Test
43 | # Builds and run tests for any not-yet-built modules, i.e. the :poko-tests modules
44 | run: ./gradlew build --stacktrace
45 |
46 | - name: Test without K2
47 | # Builds and run tests for any not-yet-built modules, i.e. the :poko-tests modules
48 | run: >-
49 | ./gradlew :poko-tests:clean build --stacktrace
50 | -Dorg.gradle.project.pokoTests.compileMode=WITHOUT_K2
51 |
52 | test-with-jdk:
53 | runs-on: ubuntu-latest
54 | strategy:
55 | fail-fast: false
56 | matrix:
57 | poko_tests_jvm_toolchain_version: [ 8, 11, 17, 21 ]
58 | steps:
59 | - name: Check out the repo
60 | uses: actions/checkout@v4
61 |
62 | - name: Install JDK ${{ matrix.poko_tests_jvm_toolchain_version }}
63 | uses: actions/setup-java@v4
64 | with:
65 | distribution: zulu
66 | java-version: |
67 | ${{ matrix.poko_tests_jvm_toolchain_version }}
68 | 23
69 |
70 | - name: Set up Gradle
71 | uses: gradle/actions/setup-gradle@v4
72 |
73 | - name: Test
74 | run: >-
75 | ./gradlew :poko-tests:jvmTest --stacktrace
76 | -Dorg.gradle.project.pokoTests.jvmToolchainVersion=${{ matrix.poko_tests_jvm_toolchain_version }}
77 |
78 | - name: Test without K2
79 | run: >-
80 | ./gradlew :poko-tests:jvmTest --stacktrace
81 | -Dorg.gradle.project.pokoTests.jvmToolchainVersion=${{ matrix.poko_tests_jvm_toolchain_version }}
82 | -Dorg.gradle.project.pokoTests.compileMode=WITHOUT_K2
83 |
84 | test-non-fir-generation:
85 | runs-on: ubuntu-latest
86 | steps:
87 | - name: Check out the repo
88 | uses: actions/checkout@v4
89 |
90 | - name: Install JDK ${{ matrix.poko_tests_jvm_toolchain_version }}
91 | uses: actions/setup-java@v4
92 | with:
93 | distribution: zulu
94 | java-version: 23
95 |
96 | - name: Set up Gradle
97 | uses: gradle/actions/setup-gradle@v4
98 |
99 | - name: Test
100 | run: ./gradlew :poko-tests:build --stacktrace -Dorg.gradle.project.pokoTests.compileMode=FIR_GENERATION_DISABLED
101 |
102 | build-sample:
103 | runs-on: ubuntu-latest
104 | needs: build
105 | strategy:
106 | fail-fast: false
107 | matrix:
108 | poko_sample_kotlin_version: [ 2.1.0, 2.1.10, ~, 2.2.0-RC ]
109 | poko_sample_kotlin_language_version: [ 1.9, ~ ]
110 | env:
111 | poko_sample_kotlin_version: ${{ matrix.poko_sample_kotlin_version }}
112 | ORG_GRADLE_PROJECT_pokoSample_kotlinLanguageVersion: ${{ matrix.poko_sample_kotlin_language_version }}
113 | steps:
114 | - name: Check out the repo
115 | uses: actions/checkout@v4
116 | - name: Install JDK
117 | uses: actions/setup-java@v4
118 | with:
119 | distribution: zulu
120 | java-version: 23
121 | - name: Download MavenLocal
122 | uses: actions/download-artifact@v4
123 | with:
124 | name: MavenLocal
125 | path: ~/.m2/repository/dev/drewhamilton/poko/
126 |
127 | - name: Set up Gradle
128 | uses: gradle/actions/setup-gradle@v4
129 |
130 | - name: Upgrade yarn lock
131 | if: ${{ matrix.poko_sample_kotlin_version != null }}
132 | run: cd sample && ./gradlew kotlinUpgradeYarnLock
133 |
134 | - name: Build sample
135 | run: cd sample && ./gradlew build --stacktrace
136 |
137 | env:
138 | GRADLE_OPTS: >-
139 | -Dorg.gradle.configureondemand=true
140 | -Dkotlin.incremental=false
141 | -Dorg.gradle.jvmargs="-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=512m"
142 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 | tags: [ "*" ]
7 |
8 | jobs:
9 | release:
10 | runs-on: macos-latest
11 |
12 | steps:
13 | - name: Check out the repo
14 | uses: actions/checkout@v4
15 |
16 | - name: Install JDK
17 | uses: actions/setup-java@v4
18 | with:
19 | distribution: zulu
20 | java-version: 23
21 |
22 | - name: Set up Gradle
23 | uses: gradle/actions/setup-gradle@v4
24 |
25 | - name: Assemble for release
26 | run: ./gradlew assemble
27 | - name: Publish
28 | run: ./gradlew publish --no-configuration-cache
29 | env:
30 | ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_personalSonatypeIssuesUsername }}
31 | ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_personalSonatypeIssuesPassword }}
32 | ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_personalGpgKey }}
33 | ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_personalGpgPassword }}
34 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/java,gradle,kotlin,intellij
3 | # Edit at https://www.gitignore.io/?templates=java,gradle,kotlin,intellij
4 |
5 | ### Intellij ###
6 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
7 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
8 |
9 | # Whitelisted .idea files:
10 | !.idea/codeStyles/*
11 |
12 | # User-specific stuff
13 | .idea/**/workspace.xml
14 | .idea/**/tasks.xml
15 | .idea/**/usage.statistics.xml
16 | .idea/**/dictionaries
17 | .idea/**/shelf
18 | .idea/**/jarRepositories.xml
19 | .idea/.name
20 | .idea/**/compiler.xml
21 | .idea/misc.xml
22 | .idea/other.xml
23 | .idea/caches
24 | .idea/runConfigurations.xml
25 |
26 | # Generated files
27 | .idea/**/artifacts
28 | .idea/**/contentModel.xml
29 | .idea/AndroidProjectSystem.xml
30 |
31 | # Sensitive or high-churn files
32 | .idea/**/dataSources/
33 | .idea/**/dataSources.ids
34 | .idea/**/dataSources.local.xml
35 | .idea/**/sqlDataSources.xml
36 | .idea/**/dynamic.xml
37 | .idea/**/uiDesigner.xml
38 | .idea/**/dbnavigator.xml
39 |
40 | # Gradle
41 | .idea/**/gradle.xml
42 | .idea/**/libraries
43 |
44 | # Gradle and Maven with auto-import
45 | .idea/modules.xml
46 | .idea/*.iml
47 | .idea/modules
48 | *.iml
49 | *.ipr
50 |
51 | # CMake
52 | cmake-build-*/
53 |
54 | # Mongo Explorer plugin
55 | .idea/**/mongoSettings.xml
56 |
57 | # File-based project format
58 | *.iws
59 |
60 | # IntelliJ
61 | out/
62 |
63 | # mpeltonen/sbt-idea plugin
64 | .idea_modules/
65 |
66 | # JIRA plugin
67 | atlassian-ide-plugin.xml
68 |
69 | # Cursive Clojure plugin
70 | .idea/replstate.xml
71 |
72 | # Crashlytics plugin (for Android Studio and IntelliJ)
73 | com_crashlytics_export_strings.xml
74 | crashlytics.properties
75 | crashlytics-build.properties
76 | fabric.properties
77 |
78 | # Editor-based Rest Client
79 | .idea/httpRequests
80 |
81 | # Android studio 3.1+ serialized cache file
82 | .idea/caches/build_file_checksums.ser
83 |
84 | ### Intellij Patch ###
85 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
86 |
87 | # *.iml
88 | # modules.xml
89 | # .idea/misc.xml
90 | # *.ipr
91 |
92 | # Sonarlint plugin
93 | .idea/**/sonarlint/
94 |
95 | # SonarQube Plugin
96 | .idea/**/sonarIssues.xml
97 |
98 | # Markdown Navigator plugin
99 | .idea/**/markdown-navigator.xml
100 | .idea/**/markdown-navigator/
101 |
102 | ### Gradle ###
103 | .gradle
104 | build/
105 | !**/src/**/build/
106 |
107 | # Local configuration file (sdk path, etc)
108 | local.properties
109 |
110 | # Ignore Gradle GUI config
111 | gradle-app.setting
112 |
113 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
114 | !gradle-wrapper.jar
115 |
116 | # Cache of project
117 | .gradletasknamecache
118 |
119 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
120 | # gradle/wrapper/gradle-wrapper.properties
121 |
122 | # End of https://www.gitignore.io/api/gradle,intellij
123 |
124 | # Kotlin
125 | .kotlin
126 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/kotlinCodeInsightSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/libraries-with-intellij-classes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
64 |
65 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## 0.18.7
4 | _2025-05-16_
5 |
6 | Fix bug in generated `toString` for `@ReadArrayContent` properties on Poko classes targeting JS:
7 | array properties would print a value of "\[...]" instead of their actual content.
8 |
9 | Compile with Kotlin 2.1.21. Add forward compatibility with Kotlin 2.2.0-RC. Compile with Java 23.
10 |
11 | ## 0.18.6
12 | _2025-04-16_
13 |
14 | Add forward compatibility with Kotlin 2.2.0-Beta1.
15 |
16 | ## 0.18.5
17 | _2025-03-31_
18 |
19 | Fix compilation error when defining a Poko class with multiple super-interfaces while using
20 | `languageVersion = KotlinVersion.KOTLIN_1_9`.
21 |
22 | ## 0.18.4
23 | _2025-03-27_
24 |
25 | Fix compilation error with `@Poko actual` classes.
26 |
27 | ## 0.18.3
28 | _2025-03-26_
29 |
30 | Fix a bug where Poko functions declared `final` in the Poko class's supertype would be overridden.
31 | Fix compilation error when Poko functions are declared `abstract` in the Poko class's supertype(s).
32 |
33 | Under the hood, generate Poko functions with FIR-based declarations backed by IR-based function
34 | bodies. This allows K2-based IDEs to recognize the overridden functions.
35 |
36 | Compile with Kotlin 2.1.20.
37 |
38 | ## 0.18.2
39 | _2024-12-27_
40 |
41 | Add forward compatibility with Kotlin 2.1.20-Beta1.
42 |
43 | ## 0.18.1
44 | _2024-12-13_
45 |
46 | Add ability to skip individual properties with `@Poko.Skip`. These properties will be omitted from
47 | all generated functions. This feature is experimental and requires opt-in via `@SkipSupport`.
48 |
49 | Replace `@ArrayContentBased` with `@Poko.ReadArrayContent`. Add a deprecated `typealias` for the
50 | former to aid migration.
51 |
52 | Add support for use optional property-level features with custom Poko annotation. Nested annotations
53 | with the same name as the optional feature, such as `@MyData.ReadArrayContent` and
54 | `@MyData.Skip`, will be respected.
55 |
56 | Fix issue with FIR checkers. K2-enabled IDEs should now highlight Poko errors and warnings in
57 | consumer source code.
58 |
59 | ## 0.18.0
60 | _2024-12-2_
61 |
62 | Compile with Kotlin 2.1.0.
63 |
64 | ## 0.17.2
65 | _2024-10-18_
66 |
67 | Compile with Kotlin 2.0.21. Implement compatibility with Kotlin 2.0.0 – 2.1.0-Beta2.
68 |
69 | ## 0.17.1
70 | _2024-09-17_
71 |
72 | Automatically add the Poko annotation dependency to test fixtures when they are enabled on JVM
73 | projects.
74 |
75 | ## 0.17.0
76 | _2024-08-22_
77 |
78 | Compile with Kotlin 2.0.20. Support Java 22.
79 |
80 | ## 0.16.0
81 | _2024-05-28_
82 |
83 | Compile with Kotlin 2.0.0. The syntax for custom annotation references now uses `/` to denote
84 | packages, e.g. `com/example/MyAnnotationClass`.
85 |
86 | Deprecate `@ArrayContentSupport` annotation and stop requiring it for using `@ArrayContentBased`
87 | annotation.
88 |
89 | ### 0.16.0-beta01
90 | _2024-05-20_
91 |
92 | Compile with Kotlin 2.0.0-RC3. The syntax for custom annotation references now uses `/` to denote
93 | packages, e.g. `com/example/MyAnnotationClass`.
94 |
95 | ## 0.15.3
96 | _2024-05-19_
97 |
98 | Support Android native targets and Wasm-WASI target for Kotlin Multiplatform. Implement error checks
99 | in FIR to support automatic IDE warnings in future IntelliJ releases.
100 |
101 | Compile with Kotlin 1.9.24. Use Node v22 for Wasm and JS targets. Compile released artifacts with
102 | `-Xjdk-release` flag to ensure JVM 1.8 compatibility.
103 |
104 | ## 0.15.2
105 | _2024-01-02_
106 |
107 | Support Wasm-JS target for Kotlin Multiplatform.
108 |
109 | Compile with Kotlin 1.9.22. Support Java 21.
110 |
111 | ## 0.15.1
112 | _2023-11-27_
113 |
114 | Compile with Kotlin 1.9.20. Support compilation with K2. Support Java 20.
115 |
116 | Optimize JS `equals` implementation as well as bytecode for `Int` and `UInt` properties.
117 |
118 | ## 0.15.0
119 | _2023-08-09_
120 |
121 | Support Kotlin Multiplatform.
122 |
123 | Revert `poko-annotations` to an `implementation` dependency, because Kotlin/Native doesn't support
124 | `compileOnly`. The annotations are still source-retention, so the end-consumer's app binary can
125 | strip the annotations from the classpath during shrinking.
126 |
127 | Update the compiler plugin to be enabled by default and to use the default annotations by default.
128 | This brings the compiler plugin into alignment with the Gradle plugin.
129 |
130 | ## 0.14.0
131 | _2023-07-06_
132 |
133 | Compile with Kotlin 1.9.0.
134 |
135 | Include default `poko-annotations` dependency as `compileOnly`, and convert `@Poko` annotation from
136 | binary retention to source retention. This makes Poko invisible to consumers of Poko-consuming
137 | libraries.
138 |
139 | Change the Kotlin Gradle plugin to a `compileOnly` dependency of the Poko Gradle plugin, allowing
140 | consumers to use older versions of Kotlin for their libraries than Poko uses (assuming compatible
141 | versions of the Kotlin compiler API).
142 |
143 | ## 0.13.1
144 | _2023-06-20_
145 |
146 | Add experimental `@ArrayContentBased` annotation. This annotation can be applied to `@Poko` class
147 | array properties to ensure that the array's content is considered for `equals`, `hashCode`, and
148 | `toString`. (By default, array content is not considered.)
149 |
150 | Compile with Kotlin 1.8.22.
151 |
152 | ## 0.13.0
153 | _2023-04-03_
154 |
155 | Support Kotlin 1.8.20.
156 |
157 | ## 0.12.0
158 | _2023-03-21_
159 |
160 | Support Kotlin 1.8.0 and 1.8.10. Support Java 19.
161 |
162 | The `pokoAnnotation` configuration property's format changes; package names are now separated by `/`
163 | instead of `.`. For example, an inner annotation class definition would look like
164 | `"com/example/MyClass.Inner"`.
165 |
166 | The primary entry point is now `PokoCompilerPluginRegistrar`, replacing `PokoComponentRegistrar`.
167 | This change is transparent to consumers of the Gradle plugin.
168 |
169 | Automatic inclusion of the legacy `@dev.drewhamilton.extracare.DataApi` artifact is removed. The
170 | consumer can still manually depend on
171 | `implementation("dev.drewhamilton.extracare:data-api-annotations:0.6.0")` if desired.
172 |
173 | ## 0.11.0
174 | _2022-06-13_
175 |
176 | Support Kotlin 1.7.0. Support Java 18.
177 |
178 | Drop support for non-IR compilation (which does not exist in Kotlin 1.7.0).
179 |
180 | ## 0.10.0
181 | _2022-04-15_
182 |
183 | Support Kotlin 1.6.20.
184 |
185 | ## 0.9.0
186 | _2021-12-04_
187 |
188 | Support Kotlin 1.6.0.
189 |
190 | ## 0.8.1
191 | _2021-06-04_
192 |
193 | Publish a Gradle plugin marker ([#54](https://github.com/drewhamilton/Poko/issues/54)). Compile with
194 | Kotlin 1.5.10.
195 |
196 | ## 0.8.0
197 | _2021-05-18_
198 |
199 | Support Kotlin 1.5.0. Support Java 16.
200 |
201 | ## 0.7.4
202 | _2021-04-28_
203 |
204 | Change the default `poko-annotations` dependency to a runtime dependency when used, rather than a
205 | compile-only dependency. This ensures it is available in alternate configurations, like JVM test and
206 | Android test configurations.
207 |
208 | ## 0.7.3
209 | _2021-03-27_
210 |
211 | Fix another bug that broke compatibility with Jetpack Compose. Poko is now compatible with Jetpack
212 | Compose 1.0.0-beta03 and Android Gradle Plugin 7.0.0-alpha12.
213 |
214 | ## 0.7.2
215 | _2021-03-21_
216 |
217 | Enforce a minimum of one property in the primary constructor of a Poko class. Previously,
218 | compilation would succeed but could cause failures down the line with unclear error messages.
219 |
220 | ## 0.7.1
221 | _2021-02-24_
222 |
223 | Fix a bug that broke compatibility with Jetpack Compose. Poko is now compatible with Jetpack Compose
224 | 1.0.0-alpha12.
225 |
226 | ## 0.7.0
227 | _2021-02-08_
228 |
229 | Rename the library from "Extra Care" to "Poko". The new artifact names are `poko-compiler-plugin`,
230 | `poko-gradle-plugin`, and `poko-annotations`. The legacy `dev.drewhamilton.extracare.DataApi`
231 | is still supported if specified.
232 |
233 | ## 0.6.0
234 | _2021-02-06_
235 |
236 | Support Kotlin 1.4.30.
237 |
238 | Add the ability to specify a custom annotation in place of the default annotation to trigger Extra
239 | Care generation on annotated classes.
240 |
241 | ## 0.5.0
242 | _2021-01-10_
243 |
244 | Support compilation in projects where IR compilation is enabled.
245 |
246 | Disable support for `inner` and `inline` classes, which are both also not supported by the `data`
247 | keyword.
248 |
249 | Add an `extraCare` Gradle extension, where the compiler plugin can be explicitly enabled or
250 | disabled.
251 |
252 | ## 0.4.0
253 | _2021-01-01_
254 |
255 | Support Kotlin 1.4.20 and 1.4.21.
256 |
257 | ## 0.3.1 (patched to 0.2.4)
258 | _2020-09-29_
259 |
260 | Add code documentation to `@DataApi`.
261 |
262 | ## 0.3.0
263 | _2020-08-19_
264 |
265 | Update to Kotlin 1.4.0.
266 |
267 | ## 0.2.3
268 | _2020-05-04_
269 |
270 | Fix `equals` and `hashCode` generation for `long` member types.
271 |
272 | ## 0.2.2
273 | _2020-05-02_
274 |
275 | Allow explicit `toString`, `equals`, and `hashCode` declarations in `@DataApi` classes. When one of
276 | these is declared explicitly, that function will not be generated by Extra Care.
277 |
278 | ## 0.2.1
279 | _2020-04-24_
280 |
281 | Publish with Gradle module metadata.
282 |
283 | ## 0.2.0
284 | _2020-04-21_
285 |
286 | Change the Gradle plugin ID so applying the plugin is less verbose:
287 | ```groovy
288 | apply plugin: 'dev.drewhamilton.extracare'
289 | ```
290 |
291 | ## 0.1.3
292 | _2020-04-19_
293 |
294 | Fix `equals` and `hashCode` generation for `float` and `double` member types. Update to Kotlin
295 | 1.3.72.
296 |
297 | Fix release process bug preventing changes from landing in 0.1.1 and 0.1.2.
298 |
299 | ## 0.1.2
300 | _2020-04-19_
301 |
302 | No changes due to release process bug.
303 |
304 | ~~Fix `equals` and `hashCode` generation for `float` and `double` member types. Update to Kotlin
305 | 1.3.72.~~
306 |
307 | ## 0.1.1
308 | _2020-03-25_
309 |
310 | No changes due to release process bug.
311 |
312 | ~~Update to Kotlin 1.3.71.~~
313 |
314 | ## 0.1.0
315 | _2020-03-20_
316 |
317 | Initial release. Create a `@DataApi` class with `equals`, `hashCode`, and `toString` generated (but
318 | no `copy` or `componentN`).
319 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Poko
2 | [](https://github.com/drewhamilton/Poko/actions/workflows/ci.yml?query=branch%3Amain)
3 |
4 | Poko is a Kotlin compiler plugin that makes writing and maintaining data model classes for public
5 | APIs easy. Like with normal Kotlin data classes, all you have to do is provide properties in your
6 | class's primary constructor. With the `@Poko` annotation, this compiler plugin automatically
7 | generates `toString`, `equals`, and `hashCode` functions. Poko is compatible with all Kotlin
8 | Multiplatform targets.
9 |
10 | ## Use
11 | Mark your class as a `@Poko class` instead of a `data class`:
12 | ```kotlin
13 | @Poko class MyData(
14 | val int: Int,
15 | val requiredString: String,
16 | val optionalString: String?,
17 | )
18 | ```
19 |
20 | And reap the benefits of a readable `toString` and working `equals` and `hashCode`. Unlike normal
21 | data classes, no `copy` or `componentN` functions are generated.
22 |
23 | Like normal data classes, Poko classes must have at least one property in their primary constructor.
24 | Non-property parameters in the primary constructor are ignored, as are non-constructor properties.
25 | Any of the three generated functions can be overridden manually, in which case Poko will not
26 | generate that function but will still generate the non-overridden functions. Using array properties
27 | is not recommended, and if they are used, it is recommended to override `equals` and `hashCode`
28 | manually.
29 |
30 | ### Annotation
31 | By default, the `dev.drewhamilton.poko.Poko` annotation is used to mark classes for Poko generation.
32 | If you prefer, you can create a different annotation and supply it to the Gradle plugin.
33 |
34 | ```groovy
35 | apply plugin: "dev.drewhamilton.poko"
36 | poko {
37 | pokoAnnotation.set "com/example/MyData"
38 | }
39 | ```
40 |
41 | Nested annotations mentioned below can optionally be added with the same name to the base annotation
42 | and used for their respective features. For example, `@MyData.ReadArrayContent` will cause the
43 | annotated property's contents to be used in the Poko-generated functions.
44 |
45 | ### Arrays
46 | By default, Poko does nothing to inspect the contents of array properties. [This aligns with the
47 | behavior of data classes](https://blog.jetbrains.com/kotlin/2015/09/feedback-request-limitations-on-data-classes/#Appendix.Comparingarrays).
48 |
49 | Poko consumers can change this behavior on a per-property basis with the `@Poko.ReadArrayContent`
50 | annotation. On properties of a typed array type, this annotation will generate a `contentDeepEquals`
51 | check. On properties of a primitive array type, this annotation will generate a `contentEquals`
52 | check. And on properties of type `Any` or of a generic type, this annotation will generate a `when`
53 | statement that disambiguates the many array types at runtime and uses the appropriate
54 | `contentDeepEquals` or `contentEquals` check. In all cases, the corresponding content-based
55 | `hashCode` and `toString` are generated for the property as well.
56 |
57 | Using arrays as properties in data types is not generally recommended: arrays are mutable, and
58 | mutating data can affect the results of `equals` and `hashCode` over time, which is generally
59 | unexpected. For this reason, `@Poko.ReadArrayContent` should only be used in very
60 | performance-sensitive APIs.
61 |
62 | ### Skipping properties
63 |
64 | It is sometimes useful to omit some properties from consideration when generating the Poko
65 | functions. This can be done with the experimental `@Poko.Skip` annotation. Properties with this
66 | annotation will be excluded from all three generated functions. For example:
67 |
68 | ```kotlin
69 | @Poko class Data(
70 | val id: String,
71 | @Poko.Skip val callback: () -> Unit,
72 | ) : CircuitUiState
73 |
74 | Data("a", { println("a") }) == Data("a", { println("not a") }) // yields `true`
75 | ```
76 |
77 | ### Download
78 |
79 | [](https://maven-badges.herokuapp.com/maven-central/dev.drewhamilton.poko/poko-compiler-plugin)
80 |
81 | Poko is available on Maven Central. It is experimental, and the API may undergo breaking changes
82 | before version 1.0.0. Kotlin compiler plugins in general are experimental and new versions of Kotlin
83 | might break something in this compiler plugin.
84 |
85 | Since the Kotlin compiler has frequent breaking changes, different versions of Kotlin are
86 | exclusively compatible with specific versions of Poko.
87 |
88 | | Kotlin version | Poko version |
89 | |-----------------|--------------|
90 | | 2.1.0 – 2.1.21 | 0.18.7 |
91 | | 2.0.0 – 2.0.21 | 0.17.2 |
92 | | 1.9.0 – 1.9.24 | 0.15.3 |
93 | | 1.8.20 – 1.8.22 | 0.13.1 |
94 | | 1.8.0 – 1.8.10 | 0.12.0 |
95 | | 1.7.0 – 1.7.21 | 0.11.0 |
96 | | 1.6.20 – 1.6.21 | 0.10.0 |
97 | | 1.6.0 – 1.6.10 | 0.9.0 |
98 | | 1.5.0 – 1.5.31 | 0.8.1 |
99 | | 1.4.30 – 1.4.32 | 0.7.4 |
100 | | 1.4.20 – 1.4.21 | 0.5.0* |
101 | | 1.4.0 – 1.4.10 | 0.3.1* |
102 | | 1.3.72 | 0.2.4* |
103 |
104 | Snapshots of the development version are available in [Sonatype's Snapshots
105 | repository](https://oss.sonatype.org/#view-repositories;snapshots~browsestorage).
106 |
107 | Releases are signed with [this key](https://keyserver.ubuntu.com/pks/lookup?search=09939C73246B4BA7444CAA453D002DBC5EA9615F&fingerprint=on&op=index).
108 | ```
109 | pub rsa4096 2020-02-02
110 | 09939C73246B4BA7444CAA453D002DBC5EA9615F
111 | uid Drew Hamilton
112 | sig 3D002DBC5EA9615F 2020-02-02
113 | ```
114 |
115 | To use Poko, apply the Gradle plugin in your project:
116 | ```kotlin
117 | // Root project:
118 | plugins {
119 | id("dev.drewhamilton.poko") apply false
120 | }
121 |
122 | // Per module:
123 | plugins {
124 | id("dev.drewhamilton.poko")
125 | }
126 | ```
127 |
128 | \*Versions prior to 0.7.0 use plugin name `dev.drewhamilton.extracare`.
129 |
130 | ## License
131 | ```
132 | Copyright 2020 Drew Hamilton
133 |
134 | Licensed under the Apache License, Version 2.0 (the "License");
135 | you may not use this file except in compliance with the License.
136 | You may obtain a copy of the License at
137 |
138 | http://www.apache.org/licenses/LICENSE-2.0
139 |
140 | Unless required by applicable law or agreed to in writing, software
141 | distributed under the License is distributed on an "AS IS" BASIS,
142 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
143 | See the License for the specific language governing permissions and
144 | limitations under the License.
145 | ```
146 |
--------------------------------------------------------------------------------
/RELEASING.md:
--------------------------------------------------------------------------------
1 | # Releasing
2 |
3 | 1. Make sure you're on the latest commit on the main branch.
4 | 2. Update CHANGELOG.md for the impending release.
5 | 3. Change `PUBLISH_VERSION` in gradle.properties to a non-SNAPSHOT version.
6 | 4. Update README.md for the impending release.
7 | 5. Commit (don't push) the changes with message "Release x.y.z", where x.y.z is the new version.
8 | 6. Tag the commit `x.y.z`, where x.y.z is the new version.
9 | 7. Change `PUBLISH_VERSION` in gradle.properties to the next SNAPSHOT version.
10 | 8. Commit the snapshot change.
11 | 9. Push the tag and 2 commits to origin/main.
12 | 10. Wait for the "Release" Action to complete.
13 | 11. Create the release on GitHub with release notes copied from the changelog.
14 |
15 | If steps 10 fails: drop the Sonatype repo, fix the problem, delete the incorrect tag on both local
16 | and remote, and start over.
17 |
--------------------------------------------------------------------------------
/build-support/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2 |
3 | plugins {
4 | `kotlin-dsl`
5 | `java-gradle-plugin`
6 | }
7 |
8 | repositories {
9 | mavenCentral()
10 | gradlePluginPortal()
11 | }
12 |
13 | dependencies {
14 | implementation(libs.kotlin.gradle)
15 | implementation(libs.plugin.buildconfig)
16 | implementation(libs.plugin.mavenPublish)
17 | implementation(libs.plugin.dokka)
18 | }
19 |
20 | java {
21 | sourceCompatibility = JavaVersion.VERSION_11
22 | targetCompatibility = JavaVersion.VERSION_11
23 | }
24 |
25 | kotlin {
26 | compilerOptions {
27 | jvmTarget.set(JvmTarget.JVM_11)
28 | }
29 | }
30 |
31 | gradlePlugin {
32 | plugins {
33 | create("build") {
34 | id = "dev.drewhamilton.poko.build"
35 | implementationClass = "dev.drewhamilton.poko.build.PokoBuildPlugin"
36 | }
37 | create("settings") {
38 | id = "dev.drewhamilton.poko.settings"
39 | implementationClass = "dev.drewhamilton.poko.build.PokoSettingsPlugin"
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/build-support/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | dependencyResolutionManagement {
2 | versionCatalogs {
3 | create("libs") {
4 | from(files("../gradle/libs.versions.toml"))
5 | }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/build-support/src/main/java/dev/drewhamilton/poko/build/PokoBuildExtension.kt:
--------------------------------------------------------------------------------
1 | package dev.drewhamilton.poko.build
2 |
3 | interface PokoBuildExtension {
4 | fun publishing(pomName: String)
5 | fun generateBuildConfig(basePackage: String)
6 | }
7 |
--------------------------------------------------------------------------------
/build-support/src/main/java/dev/drewhamilton/poko/build/PokoBuildPlugin.kt:
--------------------------------------------------------------------------------
1 | package dev.drewhamilton.poko.build
2 |
3 | import com.github.gmazzo.buildconfig.BuildConfigExtension
4 | import com.vanniktech.maven.publish.MavenPublishBaseExtension
5 | import com.vanniktech.maven.publish.SonatypeHost
6 | import org.gradle.api.Action
7 | import org.gradle.api.Plugin
8 | import org.gradle.api.Project
9 | import org.gradle.api.plugins.AppliedPlugin
10 | import org.gradle.kotlin.dsl.buildConfigField
11 | import org.gradle.kotlin.dsl.getByType
12 | import org.jetbrains.kotlin.gradle.dsl.KotlinBaseExtension
13 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
14 |
15 | private val Project.pokoGroupId get() = property("PUBLISH_GROUP") as String
16 | private val Project.pokoVersion get() = property("PUBLISH_VERSION") as String
17 |
18 | @Suppress("unused") // Invoked reflectively by Gradle.
19 | class PokoBuildPlugin : Plugin {
20 |
21 | override fun apply(target: Project) {
22 | target.group = target.pokoGroupId
23 | target.version = target.pokoVersion
24 |
25 | target.extensions.add(
26 | PokoBuildExtension::class.java,
27 | "pokoBuild",
28 | PokoBuildExtensionImpl(target)
29 | )
30 |
31 | commonKotlinConfiguration(target)
32 | }
33 |
34 | private fun commonKotlinConfiguration(project: Project) {
35 | project.tasks.withType(KotlinCompilationTask::class.java).configureEach {
36 | compilerOptions.progressiveMode.convention(true)
37 | }
38 | }
39 |
40 | private class PokoBuildExtensionImpl(
41 | private val project: Project,
42 | ) : PokoBuildExtension {
43 | override fun publishing(pomName: String) {
44 | project.pluginManager.apply("com.vanniktech.maven.publish")
45 |
46 | val mavenPublishing = project.extensions.getByName("mavenPublishing") as MavenPublishBaseExtension
47 | mavenPublishing.apply {
48 | coordinates(project.pokoGroupId, project.name, project.pokoVersion)
49 |
50 | pom {
51 | name.set(pomName)
52 |
53 | description.set("A Kotlin compiler plugin for generating equals, hashCode, and toString for plain old Kotlin objects.")
54 | url.set("https://github.com/drewhamilton/Poko")
55 |
56 | licenses {
57 | license {
58 | name.set("The Apache Software License, Version 2.0")
59 | url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
60 | distribution.set("repo")
61 | }
62 | }
63 |
64 | scm {
65 | url.set("https://github.com/drewhamilton/Poko/tree/main")
66 | connection.set("scm:git:github.com/drewhamilton/Poko.git")
67 | developerConnection.set("scm:git:ssh://github.com/drewhamilton/Poko.git")
68 | }
69 |
70 | developers {
71 | developer {
72 | id.set("drewhamilton")
73 | name.set("Drew Hamilton")
74 | email.set("software@drewhamilton.dev")
75 | }
76 | }
77 | }
78 |
79 | signAllPublications()
80 | publishToMavenCentral(
81 | host = SonatypeHost.DEFAULT,
82 | automaticRelease = true,
83 | )
84 | }
85 |
86 | project.pluginManager.apply("org.jetbrains.dokka")
87 | project.pluginManager.apply("org.jetbrains.kotlinx.binary-compatibility-validator")
88 |
89 | // Published modules should be explicit about their API visibility.
90 | val kotlinPluginHandler = Action {
91 | val kotlin = project.extensions.getByType()
92 | kotlin.explicitApi()
93 | }
94 | project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm", kotlinPluginHandler)
95 | project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform", kotlinPluginHandler)
96 | }
97 |
98 | override fun generateBuildConfig(basePackage: String) {
99 | project.pluginManager.apply("com.github.gmazzo.buildconfig")
100 |
101 | val buildConfig = project.extensions.getByName("buildConfig") as BuildConfigExtension
102 | buildConfig.apply {
103 | packageName(basePackage)
104 | buildConfigField("GROUP", project.pokoGroupId)
105 | buildConfigField("VERSION", project.pokoVersion)
106 | buildConfigField("ANNOTATIONS_ARTIFACT", "poko-annotations")
107 | buildConfigField("COMPILER_PLUGIN_ARTIFACT", "poko-compiler-plugin")
108 |
109 | buildConfigField("POKO_ENABLED_OPTION_NAME", "enabled")
110 | buildConfigField("DEFAULT_POKO_ENABLED", true)
111 |
112 | buildConfigField("POKO_ANNOTATION_OPTION_NAME", "pokoAnnotation")
113 | buildConfigField("DEFAULT_POKO_ANNOTATION", "dev/drewhamilton/poko/Poko")
114 |
115 | buildConfigField("POKO_PLUGIN_ARGS_OPTION_NAME", "pokoPluginArgs")
116 | buildConfigField("POKO_PLUGIN_ARGS_LIST_DELIMITER", ';')
117 | buildConfigField("POKO_PLUGIN_ARGS_ITEM_DELIMITER", '=')
118 | }
119 | }
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/build-support/src/main/java/dev/drewhamilton/poko/build/PokoSettingsPlugin.kt:
--------------------------------------------------------------------------------
1 | package dev.drewhamilton.poko.build
2 |
3 | import org.gradle.api.Plugin
4 | import org.gradle.api.initialization.Settings
5 |
6 | @Suppress("unused") // Invoked reflectively by Gradle.
7 | class PokoSettingsPlugin : Plugin {
8 | override fun apply(target: Settings) {
9 | target.gradle.allprojects {
10 | pluginManager.apply("dev.drewhamilton.poko.build")
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/build-support/src/main/java/dev/drewhamilton/poko/build/publish.kt:
--------------------------------------------------------------------------------
1 | package dev.drewhamilton.poko.build
2 |
3 | import org.gradle.api.Project
4 | import org.gradle.kotlin.dsl.extra
5 |
6 | fun Project.setUpLocalSigning() {
7 | val isCi = System.getenv()["CI"] == "true"
8 | if (!isCi) {
9 | extra["signing.keyId"] = findProperty("personalGpgKeyId") ?: "x"
10 | extra["signing.password"] = findProperty("personalGpgPassword") ?: "x"
11 | extra["signing.secretKeyRingFile"] = findProperty("personalGpgKeyringFile") ?: "x"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import dev.drewhamilton.poko.build.setUpLocalSigning
2 | import org.jetbrains.kotlin.gradle.dsl.JvmTarget
3 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
4 |
5 | plugins {
6 | // Note: kotlin-jvm and kotlin-multiplatform plugins are added implicitly via build-support
7 |
8 | alias(libs.plugins.kotlinx.binaryCompatibilityValidator) apply false
9 | alias(libs.plugins.ksp) apply false
10 | }
11 |
12 | allprojects {
13 | setUpLocalSigning()
14 |
15 | repositories {
16 | mavenCentral()
17 |
18 | // KSP:
19 | google()
20 |
21 | val snapshotsRepository = rootProject.findProperty("snapshots_repository")
22 | if (snapshotsRepository != null) {
23 | logger.lifecycle("Adding <$snapshotsRepository> repository for ${this@allprojects}")
24 | maven { url = uri(snapshotsRepository) }
25 | }
26 | val kotlinDevRepository = rootProject.findProperty("kotlin_dev_repository")
27 | if (kotlinDevRepository != null) {
28 | logger.lifecycle("Adding <$kotlinDevRepository> repository for ${this@allprojects}")
29 | maven { url = uri(kotlinDevRepository) }
30 | }
31 | }
32 |
33 | // The tests vary their own JVM targets among multiple targets. Do not overwrite them.
34 | if (path !in setOf(":poko-tests")) {
35 | val kotlinPluginHandler: AppliedPlugin.() -> Unit = {
36 | val javaVersion = JavaVersion.VERSION_1_8
37 | project.tasks.withType().configureEach {
38 | sourceCompatibility = javaVersion.toString()
39 | targetCompatibility = javaVersion.toString()
40 | }
41 | project.tasks.withType().configureEach {
42 | compilerOptions {
43 | jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString()))
44 | freeCompilerArgs.add("-Xjdk-release=$javaVersion")
45 | }
46 | }
47 | }
48 | pluginManager.withPlugin("org.jetbrains.kotlin.jvm", kotlinPluginHandler)
49 | pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform", kotlinPluginHandler)
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | kotlin.code.style=official
2 |
3 | # Do not include DOM compatibility dependency for JS targets.
4 | # See https://youtrack.jetbrains.com/issue/KT-35973 for more info.
5 | kotlin.js.stdlib.dom.api.included=false
6 |
7 | PUBLISH_GROUP=dev.drewhamilton.poko
8 | PUBLISH_VERSION=0.19.0-SNAPSHOT
9 |
10 | # Uncomment to enable snapshot dependencies:
11 | #snapshots_repository=https://oss.sonatype.org/content/repositories/snapshots
12 | # Uncomment to enable dev versions of Kotlin dependencies:
13 | #kotlin_dev_repository=https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev
14 |
15 | # Workaround for https://github.com/Kotlin/dokka/issues/1405 on `./gradlew dokkaJavadoc`
16 | org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m
17 |
18 | # Dokka v2
19 | org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
20 | org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
21 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 |
3 | androidx-compose-runtime = "1.8.2"
4 |
5 | kotlin = "2.1.21"
6 | kotlinCompileTesting = "1.6.0"
7 | # https://central.sonatype.com/artifact/dev.zacsweers.kctfork/core/versions:
8 | kotlinCompileTestingFork = "0.7.1"
9 | # https://github.com/google/ksp/releases:
10 | ksp = "2.1.21-2.0.1"
11 |
12 | [libraries]
13 |
14 | androidx-compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "androidx-compose-runtime" }
15 |
16 | autoService-annotations = { module = "com.google.auto.service:auto-service-annotations", version = "1.1.1" }
17 | autoService-ksp = { module = "dev.zacsweers.autoservice:auto-service-ksp", version = "1.2.0" }
18 |
19 | junit = { module = "junit:junit", version = "4.13.2" }
20 |
21 | kotlinCompileTesting = { module = "com.github.tschuchortdev:kotlin-compile-testing", version.ref = "kotlinCompileTesting" }
22 | kotlinCompileTestingFork = { module = "dev.zacsweers.kctfork:core", version.ref = "kotlinCompileTestingFork" }
23 |
24 | kotlin-embeddableCompiler = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable", version.ref = "kotlin" }
25 | kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
26 | kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
27 | kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
28 | kotlin-gradleApi = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin-api", version.ref = "kotlin" }
29 |
30 | assertk = "com.willowtreeapps.assertk:assertk:0.28.1"
31 | asm-util = "org.ow2.asm:asm-util:9.8"
32 | testParameterInjector = "com.google.testparameterinjector:test-parameter-injector:1.18"
33 |
34 | plugin-buildconfig = "com.github.gmazzo.buildconfig:plugin:5.6.5"
35 | plugin-mavenPublish = "com.vanniktech:gradle-maven-publish-plugin:0.32.0"
36 | plugin-dokka = "org.jetbrains.dokka:dokka-gradle-plugin:2.0.0"
37 |
38 | [plugins]
39 |
40 | android-library = { id = "com.android.library", version = "8.10.1" }
41 | kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
42 | kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
43 | kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
44 | kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
45 | kotlinx-binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.17.0" }
46 | ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
47 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/drewhamilton/Poko/15214b7c01e3e080dcba61079fc9ffdaddb775d5/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | # SPDX-License-Identifier: Apache-2.0
19 | #
20 |
21 | ##############################################################################
22 | #
23 | # Gradle start up script for POSIX generated by Gradle.
24 | #
25 | # Important for running:
26 | #
27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28 | # noncompliant, but you have some other compliant shell such as ksh or
29 | # bash, then to run this script, type that shell name before the whole
30 | # command line, like:
31 | #
32 | # ksh Gradle
33 | #
34 | # Busybox and similar reduced shells will NOT work, because this script
35 | # requires all of these POSIX shell features:
36 | # * functions;
37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39 | # * compound commands having a testable exit status, especially «case»;
40 | # * various built-in commands including «command», «set», and «ulimit».
41 | #
42 | # Important for patching:
43 | #
44 | # (2) This script targets any POSIX shell, so it avoids extensions provided
45 | # by Bash, Ksh, etc; in particular arrays are avoided.
46 | #
47 | # The "traditional" practice of packing multiple parameters into a
48 | # space-separated string is a well documented source of bugs and security
49 | # problems, so this is (mostly) avoided, by progressively accumulating
50 | # options in "$@", and eventually passing that to Java.
51 | #
52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54 | # see the in-line comments for details.
55 | #
56 | # There are tweaks for specific operating systems such as AIX, CygWin,
57 | # Darwin, MinGW, and NonStop.
58 | #
59 | # (3) This script is generated from the Groovy template
60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61 | # within the Gradle project.
62 | #
63 | # You can find Gradle at https://github.com/gradle/gradle/.
64 | #
65 | ##############################################################################
66 |
67 | # Attempt to set APP_HOME
68 |
69 | # Resolve links: $0 may be a link
70 | app_path=$0
71 |
72 | # Need this for daisy-chained symlinks.
73 | while
74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75 | [ -h "$app_path" ]
76 | do
77 | ls=$( ls -ld "$app_path" )
78 | link=${ls#*' -> '}
79 | case $link in #(
80 | /*) app_path=$link ;; #(
81 | *) app_path=$APP_HOME$link ;;
82 | esac
83 | done
84 |
85 | # This is normally unused
86 | # shellcheck disable=SC2034
87 | APP_BASE_NAME=${0##*/}
88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH="\\\"\\\""
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | if ! command -v java >/dev/null 2>&1
137 | then
138 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
139 |
140 | Please set the JAVA_HOME variable in your environment to match the
141 | location of your Java installation."
142 | fi
143 | fi
144 |
145 | # Increase the maximum file descriptors if we can.
146 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
147 | case $MAX_FD in #(
148 | max*)
149 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
150 | # shellcheck disable=SC2039,SC3045
151 | MAX_FD=$( ulimit -H -n ) ||
152 | warn "Could not query maximum file descriptor limit"
153 | esac
154 | case $MAX_FD in #(
155 | '' | soft) :;; #(
156 | *)
157 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
158 | # shellcheck disable=SC2039,SC3045
159 | ulimit -n "$MAX_FD" ||
160 | warn "Could not set maximum file descriptor limit to $MAX_FD"
161 | esac
162 | fi
163 |
164 | # Collect all arguments for the java command, stacking in reverse order:
165 | # * args from the command line
166 | # * the main class name
167 | # * -classpath
168 | # * -D...appname settings
169 | # * --module-path (only if needed)
170 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
171 |
172 | # For Cygwin or MSYS, switch paths to Windows format before running java
173 | if "$cygwin" || "$msys" ; then
174 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
175 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
176 |
177 | JAVACMD=$( cygpath --unix "$JAVACMD" )
178 |
179 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
180 | for arg do
181 | if
182 | case $arg in #(
183 | -*) false ;; # don't mess with options #(
184 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
185 | [ -e "$t" ] ;; #(
186 | *) false ;;
187 | esac
188 | then
189 | arg=$( cygpath --path --ignore --mixed "$arg" )
190 | fi
191 | # Roll the args list around exactly as many times as the number of
192 | # args, so each arg winds up back in the position where it started, but
193 | # possibly modified.
194 | #
195 | # NB: a `for` loop captures its iteration list before it begins, so
196 | # changing the positional parameters here affects neither the number of
197 | # iterations, nor the values presented in `arg`.
198 | shift # remove old arg
199 | set -- "$@" "$arg" # push replacement arg
200 | done
201 | fi
202 |
203 |
204 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
205 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
206 |
207 | # Collect all arguments for the java command:
208 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209 | # and any embedded shellness will be escaped.
210 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
211 | # treated as '${Hostname}' itself on the command line.
212 |
213 | set -- \
214 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
215 | -classpath "$CLASSPATH" \
216 | -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217 | "$@"
218 |
219 | # Stop when "xargs" is not available.
220 | if ! command -v xargs >/dev/null 2>&1
221 | then
222 | die "xargs is not available"
223 | fi
224 |
225 | # Use "xargs" to parse quoted args.
226 | #
227 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
228 | #
229 | # In Bash we could simply go:
230 | #
231 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
232 | # set -- "${ARGS[@]}" "$@"
233 | #
234 | # but POSIX shell has neither arrays nor command substitution, so instead we
235 | # post-process each arg (as a line of input to sed) to backslash-escape any
236 | # character that might be a shell metacharacter, then use eval to reverse
237 | # that process (while maintaining the separation between arguments), and wrap
238 | # the whole thing up as a single "set" statement.
239 | #
240 | # This will of course break if any of these variables contains a newline or
241 | # an unmatched quote.
242 | #
243 |
244 | eval "set -- $(
245 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
246 | xargs -n1 |
247 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
248 | tr '\n' ' '
249 | )" '"$@"'
250 |
251 | exec "$JAVACMD" "$@"
252 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/poko-annotations/api/poko-annotations.api:
--------------------------------------------------------------------------------
1 | public abstract interface annotation class dev/drewhamilton/poko/ArrayContentSupport : java/lang/annotation/Annotation {
2 | }
3 |
4 | public abstract interface annotation class dev/drewhamilton/poko/Poko : java/lang/annotation/Annotation {
5 | }
6 |
7 | public abstract interface annotation class dev/drewhamilton/poko/Poko$ReadArrayContent : java/lang/annotation/Annotation {
8 | }
9 |
10 | public abstract interface annotation class dev/drewhamilton/poko/Poko$Skip : java/lang/annotation/Annotation {
11 | }
12 |
13 | public abstract interface annotation class dev/drewhamilton/poko/SkipSupport : java/lang/annotation/Annotation {
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/poko-annotations/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
2 |
3 | plugins {
4 | id("org.jetbrains.kotlin.multiplatform")
5 | }
6 |
7 | pokoBuild {
8 | publishing("Poko Annotations")
9 | }
10 |
11 | kotlin {
12 | jvm()
13 |
14 | js().nodejs()
15 |
16 | mingwX64()
17 |
18 | linuxArm64()
19 | linuxX64()
20 |
21 | iosArm64()
22 | iosSimulatorArm64()
23 | iosX64()
24 |
25 | macosArm64()
26 | macosX64()
27 |
28 | tvosArm64()
29 | tvosX64()
30 | tvosSimulatorArm64()
31 |
32 | @OptIn(ExperimentalWasmDsl::class)
33 | wasmJs().nodejs()
34 | @OptIn(ExperimentalWasmDsl::class)
35 | wasmWasi().nodejs()
36 |
37 | watchosArm32()
38 | watchosArm64()
39 | watchosDeviceArm64()
40 | watchosSimulatorArm64()
41 | watchosX64()
42 |
43 | androidNativeArm32()
44 | androidNativeArm64()
45 | androidNativeX86()
46 | androidNativeX64()
47 | }
48 |
--------------------------------------------------------------------------------
/poko-annotations/src/commonMain/kotlin/dev/drewhamilton/poko/ArrayContentBased.kt:
--------------------------------------------------------------------------------
1 | package dev.drewhamilton.poko
2 |
3 | /**
4 | * Legacy name for [Poko.ReadArrayContent].
5 | */
6 | @Deprecated(
7 | message = "Moved to @Poko.ReadArrayContent for compatibility with custom Poko annotation",
8 | replaceWith = ReplaceWith("Poko.ReadArrayContent"),
9 | )
10 | public typealias ArrayContentBased = Poko.ReadArrayContent
11 |
--------------------------------------------------------------------------------
/poko-annotations/src/commonMain/kotlin/dev/drewhamilton/poko/Poko.kt:
--------------------------------------------------------------------------------
1 | package dev.drewhamilton.poko
2 |
3 | /**
4 | * A `@Poko class` is similar to a `data class`: the Poko compiler plugin will generate [equals],
5 | * [hashCode], and [toString] functions for any Kotlin class marked with this annotation. Unlike
6 | * normal data classes, `copy` or `componentN` functions are not generated. This makes it easier to
7 | * maintain data models in libraries without breaking binary compatibility.
8 | *
9 | * The generated functions will be based on class properties in the primary constructor. Class
10 | * properties not in the primary constructor will not be included, and primary constructor
11 | * parameters that are not class properties will not be included. Compilation will fail if the
12 | * annotated class does not include a primary constructor.
13 | *
14 | * Each function will only be generated if it is not already manually overridden in the annotated
15 | * class.
16 | *
17 | * The annotated class cannot be a `data class`, an `inline class`, or an `inner class`.
18 | *
19 | * Like data classes, it is highly recommended that all properties used in equals/hashCode are
20 | * immutable. `var`s, mutable collections, and especially arrays should be avoided. The class itself
21 | * should also be final. The compiler plugin does not enforce these recommendations.
22 | */
23 | @Retention(AnnotationRetention.SOURCE)
24 | @Target(AnnotationTarget.CLASS)
25 | public annotation class Poko {
26 |
27 | /**
28 | * Primary constructor properties marked with this annotation will be omitted from generated
29 | * `equals`, `hashCode`, and `toString` functions, as if they were not properties.
30 | *
31 | * This annotation has no effect on properties declared outside the primary constructor.
32 | */
33 | @SkipSupport
34 | @Retention(AnnotationRetention.SOURCE)
35 | @Target(AnnotationTarget.PROPERTY)
36 | public annotation class Skip
37 |
38 | /**
39 | * Declares that a [Poko] class's generated functions will be based on this property's array
40 | * content. This differs from the Poko class (and data class) default of comparing arrays by
41 | * reference only.
42 | *
43 | * Poko class properties of type [Array], [BooleanArray], [CharArray], [ByteArray], [ShortArray],
44 | * [IntArray], [LongArray], [FloatArray], and [DoubleArray] are supported, including nested
45 | * [Array] types.
46 | *
47 | * Properties of a generic type or of type [Any] are also supported. For these properties, Poko will
48 | * generate a `when` statement that disambiguates the various array types at runtime and analyzes
49 | * content if the property is an array. (Note that with this logic, typed arrays will never be
50 | * considered equals to primitive arrays, even if they hold the same content. For example,
51 | * `arrayOf(1, 2)` will not be considered equals to `intArrayOf(1, 2)`.)
52 | *
53 | * Properties of a value class type that wraps an array are not supported. Tagging non-array
54 | * properties with this annotation is an error.
55 | *
56 | * Using array properties in data models is not generally recommended, because they are mutable.
57 | * Mutating an array marked with this annotation will cause the parent Poko class to produce
58 | * different `equals` and `hashCode` results at different times. This annotation should only be used
59 | * by consumers for whom performant code is more important than safe code.
60 | */
61 | @Retention(AnnotationRetention.SOURCE)
62 | @Target(AnnotationTarget.PROPERTY)
63 | public annotation class ReadArrayContent
64 | }
65 |
--------------------------------------------------------------------------------
/poko-annotations/src/commonMain/kotlin/dev/drewhamilton/poko/optInAnnotations.kt:
--------------------------------------------------------------------------------
1 | package dev.drewhamilton.poko
2 |
3 | /**
4 | * Denotes an experimental API that enables the ability to skip a Poko class primary constructor
5 | * property when generating Poko functions.
6 | */
7 | @RequiresOptIn
8 | public annotation class SkipSupport
9 |
10 | /**
11 | * Denotes an API that enables support for array content reading, which is experimental and may
12 | * change or break.
13 | */
14 | @Deprecated("Array content support no longer requires opt-in")
15 | @RequiresOptIn
16 | public annotation class ArrayContentSupport
17 |
--------------------------------------------------------------------------------
/poko-compiler-plugin/api/poko-compiler-plugin.api:
--------------------------------------------------------------------------------
1 | public final class dev/drewhamilton/poko/PokoCommandLineProcessor : org/jetbrains/kotlin/compiler/plugin/CommandLineProcessor {
2 | public fun ()V
3 | public fun getPluginId ()Ljava/lang/String;
4 | public fun getPluginOptions ()Ljava/util/Collection;
5 | public fun processOption (Lorg/jetbrains/kotlin/compiler/plugin/AbstractCliOption;Ljava/lang/String;Lorg/jetbrains/kotlin/config/CompilerConfiguration;)V
6 | }
7 |
8 | public final class dev/drewhamilton/poko/PokoCompilerPluginRegistrar : org/jetbrains/kotlin/compiler/plugin/CompilerPluginRegistrar {
9 | public fun ()V
10 | public fun getSupportsK2 ()Z
11 | public fun registerExtensions (Lorg/jetbrains/kotlin/compiler/plugin/CompilerPluginRegistrar$ExtensionStorage;Lorg/jetbrains/kotlin/config/CompilerConfiguration;)V
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/poko-compiler-plugin/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2 |
3 | plugins {
4 | id("org.jetbrains.kotlin.jvm")
5 | alias(libs.plugins.ksp)
6 | }
7 |
8 | pokoBuild {
9 | publishing("Poko Compiler Plugin")
10 | generateBuildConfig("dev.drewhamilton.poko")
11 | }
12 |
13 | dependencies {
14 | // The stdlib and compiler APIs will be provided by the enclosing Kotlin compiler environment.
15 | compileOnly(libs.kotlin.stdlib)
16 | compileOnly(libs.kotlin.embeddableCompiler)
17 |
18 | compileOnly(libs.autoService.annotations)
19 | ksp(libs.autoService.ksp)
20 |
21 | testImplementation(project(":poko-annotations"))
22 | testImplementation(libs.kotlin.embeddableCompiler)
23 | testImplementation(libs.junit)
24 | testImplementation(libs.assertk)
25 | testImplementation(libs.testParameterInjector)
26 | testImplementation(libs.kotlinCompileTestingFork)
27 | }
28 |
29 | tasks.withType().configureEach {
30 | compilerOptions {
31 | freeCompilerArgs.add("-Xcontext-receivers")
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/poko-compiler-plugin/gradle.properties:
--------------------------------------------------------------------------------
1 | # We want the stdlib as a compileOnly dependency.
2 | kotlin.stdlib.default.dependency=false
3 |
--------------------------------------------------------------------------------
/poko-compiler-plugin/src/main/kotlin/dev/drewhamilton/poko/CompilerOptions.kt:
--------------------------------------------------------------------------------
1 | package dev.drewhamilton.poko
2 |
3 | import org.jetbrains.kotlin.config.CompilerConfigurationKey
4 |
5 | internal object CompilerOptions {
6 | val ENABLED = CompilerConfigurationKey(BuildConfig.POKO_ENABLED_OPTION_NAME)
7 | val POKO_ANNOTATION = CompilerConfigurationKey(BuildConfig.POKO_ANNOTATION_OPTION_NAME)
8 | val POKO_PLUGIN_ARGS =
9 | CompilerConfigurationKey