Add RelocatingClassLoader to fix custom ruleset JARs#799
Add RelocatingClassLoader to fix custom ruleset JARs#799paul-dingemans merged 8 commits intonbadal:mainfrom
Conversation
9651c02 to
cd120dc
Compare
516c0f9 to
91306bd
Compare
91306bd to
0f6fa1a
Compare
ktlint-plugin/src/main/kotlin/com/nbadal/ktlint/RelocatingClassLoader.kt
Outdated
Show resolved
Hide resolved
paul-dingemans
left a comment
There was a problem hiding this comment.
Thank you so much for this contribution. I couldn't wrap my head around it myzelf. The code is clear, although I would have less intermediate variables myself. There is no need to change that though.
ktlint-plugin/src/main/kotlin/com/nbadal/ktlint/RelocatingClassLoader.kt
Show resolved
Hide resolved
ktlint-plugin/src/main/kotlin/com/nbadal/ktlint/RelocatingClassLoader.kt
Outdated
Show resolved
Hide resolved
|
@paul-dingemans thanks for the feedback! I think I've addressed all your comments.
I generally prefer that too. I did a pass and inlined everything that I could (I think). Feel free to make any edits you like as well - I have the "Allow edits by maintainers" option on 🙂 |
ktlint-plugin/src/main/kotlin/com/nbadal/ktlint/RelocatingClassLoader.kt
Show resolved
Hide resolved
ktlint-plugin/src/main/kotlin/com/nbadal/ktlint/RelocatingClassLoader.kt
Show resolved
Hide resolved
ktlint-plugin/src/main/kotlin/com/nbadal/ktlint/RelocatingClassLoader.kt
Show resolved
Hide resolved
|
I will release a beta version tomorrow. It would be great if you can validate that version once more. After that I can release the stable version. It can take up to business days before it is approved by Jetbrains. |
|
Version 0.30.4.-0-beta-1 has been published |
|
@paul-dingemans The beta build works great for me! 🚀 🚀 🚀 🚀 |
Thanks for confirmation,. Stable release is being published now. It might take up to two business days before it is approved by JetBrains. Once more, thanks for contributing! |
Fixes #786
Description
9de656b broke custom rulesets JARs because the plugin now relocates
org.jetbrains.kotlintoshadow.org.jetbrains.kotlin.This PR transforms custom ruleset bytecode at load time using IntelliJ's bundled ASM library, remapping package references to match the shadow-relocated packages.
Testing
Note to reviewer(s)
I'm not an expert with IntelliJ plugin development or Java internals, so please feel free to redirect me towards better approaches. Also let me know if there's a unit test you'd like to see here - I wasn't sure how to test this in a reasonable way.
Thanks for all your work on
ktlint!