Closed canatella closed 8 months ago
What do you mean with "embedding in another project"? Do you integrate in another than one of the ways described on https://pinterest.github.io/ktlint/latest/install/integrations/? Why do you want to do it differently?
In ktlint-intellij-plugin there was also a need to really embed ktlint into the plugin. In that project the ktlint library was wrapped into a library; with the shadow plugin the org.jetbrains
packages have been moved to a different location to avoid class loading conflict.
I'm trying to add support to https://github.com/fwcd/kotlin-language-server to be able to have it format files using ktlint, see https://github.com/fwcd/kotlin-language-server/issues/303. At the moment I'm just doing
val ktLintRuleEngine = KtLintRuleEngine(
ruleProviders = StandardRuleSetProvider().getRuleProviders()
)
The problem is most likely caused by conflicting dependencies in your project (https://github.com/fwcd/kotlin-language-server/blob/main/platform/build.gradle.kts#L16-L26) and similar but not identical dependencies of Ktlint. This is the same problem that the ktlint-intellij-plugin
had. So in ktlint plugin a lib is created in which the Ktlint dependencies are relocated to a different package (https://github.com/nbadal/ktlint-intellij-plugin/blob/main/lib/build.gradle.kts#L44). Then the lib is included in the plugin app instead of including the Ktlint dependencies (https://github.com/nbadal/ktlint-intellij-plugin/blob/main/settings.gradle.kts#L7).
Expected Behavior
When embedding ktlint 1.1.1 in another project, I get this exception when running the project:
I tried to ensure the kotlin compiler version is 1.9.22 as in ktlint 1.1.1, here is the class path:
.editorconfig
settings N/A ?