Skip to content

Add 'readLenient' function to 'KotlinModuleMetadata'. - #7644

Open
Tony Robalik (autonomousapps) wants to merge 11 commits into
JetBrains:masterfrom
autonomousapps:trobalik.kmm-lenient
Open

Add 'readLenient' function to 'KotlinModuleMetadata'.#7644
Tony Robalik (autonomousapps) wants to merge 11 commits into
JetBrains:masterfrom
autonomousapps:trobalik.kmm-lenient

Conversation

@autonomousapps

Copy link
Copy Markdown

Replaces #6956.

I use that function [here](https://github.com/autonomousapps/dependency-analysis-gradle-plugin/blob/22dcdfeb5a2f5a18c709b9c8f3c50692805a7c3a/src/main/kotlin/com/autonomousapps/model/internal/KtFile.kt#L54) in my Gradle plugin. Some collaborators and I recently had to go back and forth for almost two months to find a solution in [this PR](autonomousapps/dependency-analysis-gradle-plugin#1719) for the lack of lenient read support. I use the analogous `KotlinClassMetadata.readLenient()` in two places, [here](https://github.com/autonomousapps/dependency-analysis-gradle-plugin/blob/22dcdfeb5a2f5a18c709b9c8f3c50692805a7c3a/src/main/kotlin/com/autonomousapps/tasks/FindKotlinMagicTask.kt#L325) for example.

I only need to read Kotiln metadata, not write it. My plugin analyzes class files to provide dependency-related advice to Android, JVM, and KMP projects. This missing API / TODO caused me a lot of trouble and I wanted to contribute back instead of just complain about it.

I'm aware of the deficiencies in the PR. I wasn't sure of the appetite for a contribution so this was my test. I looked for tests and didn't find anything obvious. Pointers are welcome.

I will note that the `KotlinClassMetadata` class uses a mutable var for the writability check, so I'm not sure that my immutable boolean in the constructor is that much worse. But of course I'd be willing to change things to match project standards.
because read() is used during bootstrap process in Gradle buildscript
@kotlin-safemerge

kotlin-safemerge Bot commented Aug 21, 2026

Copy link
Copy Markdown

Code Owners

RuleOwnersApproval
/​libraries/​kotlinx-​metadata/​ilya-g, qwwdfsad 🌴, sandwwraith, udalov
sandwwraith
**.​gradle.​kts, /​repo/​sellmair
kotlin-build-infrastructure

UNASSIGNED
/​libraries/​tools/​abi-​comparator, /​libraries/​tools/​kotlinp/​jvm/​
kotlin-jvm

UNASSIGNED
PR commands for maintainers
CommandDescriptionParameters
/safe-mergeRebase-merges with automatic fixup commit squashing--fixup Autosquash fixup commits (on by default)
/safe-squash-mergeSquash-merges with optional commit title/body override--title Title of the squashed commit
--message Body of the squashed commit
/dry-runRuns the test pipeline with changes rebased on latest master--retry Retry the CI run on failure
/test-publicTriggers the public test suite without rebasing on latest master
/test-privateTriggers the private test suite without rebasing on latest master
/codeownersTriggers code owners check and comment update
/fixupSquashes fixup commits and force pushes the branch
/cancel-coordinatorCancels the merge coordinator currently running for this branch

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.

3 participants