Loading a specific resource from a module must use class from module#5008
Loading a specific resource from a module must use class from module#5008BraisGabin merged 1 commit intomainfrom
Conversation
|
To be honest I don't understand how all the resources are loaded. I have little experience in load code dynamically. Is there an easy way to test this to avoid regressions? |
|
@BraisGabin there were some issues raised in the detekt-intellij-plugin repo that reveal this mentioned problem. For instance: |
|
We can merge this for sure. I'm just wondering if there is a way to unit test it. I assume there isn't. |
Hm, maybe you linked a wrong issue but this issue seems to be more a detekt-core problem with Intellij 2022.2-EAP. Seems like there will be a breaking change in the Kotlin compiler potentially.
It should be possible to write an integration test for |
Image following scenario:
A tool (e.g. IntelliJ plugin) uses
detekt-toolingto run detekt.The tool does not include the detekt jars by default (no
implementation("detekt-core")usage) but loads them dynamically.For example the user can specify the detekt version and plugin jars. The tool downloads
cli-all.jarand the plugin jars, loads them via aURLClassLoader, gets aDetektProvider.get(): Detektinstance and runs detekt.Notice that the tool must use the
detekt-toolingapi which is not inside theURLClassLoader(!).ExtensionSpecwas loaded via the AppClassLoader (ClassLoader which wants to load detekt dynamically where detekt-tooling is known).ExtensionSpec.javaClass.getResourcewon't find thedefault-detekt-config.ymlfile.Conclusion: when loading detekt core and all plugins dynamically detekt's modules are not allowed to use the
ClassLoaderfromdetekt-toolingordetekt-api.