Open stMayhem opened 3 years ago
ktlint-idea
10.1.0 should be downloadable from Gradle plugins.
Will it possible to provide repro project?
[Archive.zip] I created example project with this error. To reproduce it is required to uncomment the marked line.
@Tapchicoma Hello. Have you checked the code?
@stMayhem in the provided archive.zip
I see only some non-related screenshots :thinking:
my bad, I don't know how it could have happened...here is the correct archive: https://drive.google.com/file/d/1K66laEgYJC-_GdbnFD6FR_F_3pFrYyPN/view?usp=sharing
You just need to add into root project build.gradle.kts
following lines:
plugins {
id("org.jlleitschuh.gradle.ktlint")
id("org.jlleitschuh.gradle.ktlint-idea")
}
And in buildSrc/build.gradle.kts
you could remove this one:
//implementation("org.jlleitschuh.gradle:ktlint-idea:10.1.0")
When you are adding plugin to buildSrc
module dependencies, you need only this artifact: implementation("org.jlleitschuh.gradle:ktlint-gradle:10.1.0")
Yes, now everything works, thanks a lot. But after calling the git hook, files with incorrect formatting are not added to the commit. Is this the expected behavior? I use git commit -m ""
, correct formating files are commited, incorrect formatting files are not staged for commit.
Git hook only checks staged files. So if your unstaged files have some code style violations - they will not be formatted.
yes, I use git add .
before commit, all files were staged before hook, but after the commit it are not staged again
I figured it out, the script doesn't add files in which the format has changed to the wrong one and there have been no other changes. If there were other changes in the file, then everything is ok.
After running
./gradlew addKtlintFormatGitPreCommitHook
I'm getting this error:This is my build.gradle.kts file in buildSrc folder:
Main plugin ktlint-gradle:10.1.0 works great.