jeremymailen / kotlinter-gradle

Painless, fast ktlint plugin for Gradle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

rasros opened this issue · comments

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

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.

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.

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.