JLLeitschuh / ktlint-gradle

A ktlint gradle plugin
MIT License
1.46k stars 160 forks source link

Using ktlint-gradle with ktlint-intellij-plugin and baseline file #753

Open Rshalika opened 6 months ago

Rshalika commented 6 months ago

Hello,

I want to be able to use ktlint-gradle integration together with the official Ktlint plugin for intelliJ IDEA. Problems start when I try to also keep the baseline file for both ktlint-gradle and IntelliJ plugin. When I run ktlintGenerateBaseline it generates baseline for submodule (app module in my case for Android). But, IntelliJ plugin expects the baseline generated from the root directory of the project.

I have opened an [issue] (https://github.com/nbadal/ktlint-intellij-plugin/issues/472) in intelliJ plugin repo which describes what is an exact problem in my case. TLDR: it is about <file name="app/src/ vs <file name="src/

In the documentation I can read that "One baseline file is generated per one Gradle project (module)." My question is, is there a way to generate the baseline file from the root project directory?

I tried to generate a baseline with just ktlint command line from the root project directory and pass that file as baseline configuration but that did not work. ktlintCheck still shows all the errors that are in baseline.

I also tried to only apply ktlint-gradle in the root gradle file and then run ktlintGenerateBaseline. And it generated an empty baseline file. (Even if I have some kotlin files in the root directory with some errors it still generates an empty baseline file).

to go back to this "One baseline file is generated per one Gradle project (module)." what does project and model refer to in this statement?