$ ./gradlew check
...
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':{myModuleName}:spotlessKotlinCheck' (type 'SpotlessCheck').
> Directory '{pathToProject}/{myModuleName}/build/spotless/spotlessKotlin' specified for property 'spotlessOutDirectory' does not exist.
Gradle 6.7.1
Spotless 5.8.2
macOS 10.14.6 (18G6042)
spotless {
format 'misc', {
target '**/*.gradle', '**/*.properties', '**/*.md', '**/.gitignore', '**/*.yml'
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
kotlin {
ktlint()
}
}
gradlew spotless[Apply/Check] --stacktraceSee summary above.
The problem is solved if I specify Kotlin targets:
diff --git a/build.gradle b/build.gradle
index 80187b5..442ebe2 100644
--- a/build.gradle
+++ b/build.gradle
@@ -122,6 +122,7 @@ subprojects {
endWithNewline()
}
kotlin {
+ target '**/src/**/*.kt', '**/src/**/*.kts'
ktlint()
}
}
Now the problem has solved itself. 馃槙
I was running 'CtrlCtrl gradle check Enter' from Android Studio. That lead to the problem above. When running ./gradlew check from CLI there was no issue. (???) Then, when running it from AS again, the issue was gone. (???) Even when doing a Gradle clean (which removes the missing directory) before check doesn't reproduce the issue.
I'm confused.
Interesting. Each format has three tasks. In your case, there is spotlessKotlin, spotlessKotlinCheck, and spotlessKotlinApply.
The job of spotlessKotlin is to check the formatting of target, and write the correctly formatted result into build/spotless/spotlessKotlin. The spotlessKotlin task has up-to-date checking, buildcache, etc.
The other two tasks, check and apply, just look at the build/spotless/spotlessKotlin directory, but they do not support up-to-date, buildcache, etc. Well, they kind of do, but only in that spotlessKotlin does all of the actual computation and work, and then check and apply just interpret that result.
For a clean build, the directory needed by spotlessKotlinCheck and spotlessKotlinApply does not exist, because it is created by spotlessKotlin.
Since check and apply don't have any outputs (as far as Gradle is concerned), I wonder if we should not declare any inputs either... @bigdaz any thoughts on this?
Related to this, we should enable support for @IgnoreEmptyDirectories when used on Gradle 6.8+