jeremymailen / kotlinter-gradle

Painless, fast ktlint plugin for Gradle
Apache License 2.0
597 stars 50 forks source link

.editorconfig is ignored when plugin is loaded through a custom plugin #312

Closed rasros closed 1 year ago

rasros commented 1 year ago

How to reproduce:

buildSrc/build.gradle.kts

plugins {
    `kotlin-dsl`
}

repositories {
    gradlePluginPortal()
}

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
    implementation("org.jmailen.kotlinter:org.jmailen.kotlinter.gradle.plugin:3.13.0")
}

buildSrc/src/my.plugin.gradle.kts

import org.jmailen.gradle.kotlinter.KotlinterExtension

plugins {
    id("org.jmailen.kotlinter")
}

kotlinter {
   // ... this is working fine
}

submodule/build.gradle.kts

plugins {
    `my-plugin`
}
...

The remaining code in this module under src directory is what I want to format.

.editorconfig

These settings are however ignored:

root=true

[*.{kt,kts}]
indent_size=2
# everything here is ignroed
jeremymailen commented 1 year ago

I have it set up almost the same in projects which I lint and it seems to be working. I'll need to investigate more. The only difference is instead of your submodule style I have this in the root build file

allprojects {
    apply plugin: 'org.jmailen.kotlinter'
}

Have you tried restarting the gradle daemon after making changes to your .editorconfig file? I think that bug got fixed at some point, but that used to be a confuser with settings in .editorconfig seemingly not get picked up.

atteheino commented 1 year ago

After updating to 3.14.0 I started receiving this.

Property 'ktlint_disabled_rules' is deprecated: Update all your all '.editorconfig' files. See https://pinterest.github.io/ktlint/faq/#why-is-editorconfig-property-disabled_rules-deprecated-and-how-do-i-resolve-this for more information

I had to kill the Gradle daemon for the changes to .editorconfig to take effect. After that, things started working again.

jeremymailen commented 1 year ago

Ok, yeah the deprecation message is expected as the they've switched over to a disable line per rule you want to configure. Sounds like it's working so I can close for now. Although, beyond the first time, you shouldn't have to kill the Gradle daemon again -- the plugin sound check the editor config files and clear the cache if it can resolve them in the expected places although that might not be perfect.