-
Notifications
You must be signed in to change notification settings - Fork 488
Description
One could be tempted to exclude a directory via targetExclude, e.g. project.layout.buildDirectory
spotless {
scala {
toggleOffOn()
targetExclude(project.layout.buildDirectory)
scalafmt('2.7.5').configFile(configPath + '/enforcement/spotless-scalafmt.conf')
}
}However this doesn't work as it's not handled specifically. So when the task is configured, it uses the dir as a regular "file", and the operation here does nothing (target and targetExclude are FileCollection)
spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java
Line 1078 in d3a160d
| FileCollection totalTarget = targetExclude == null ? target : target.minus(targetExclude); |
The alternative is to expand this to a FileTree before passing it to targetExclude. In this case the operation above correctly removes the files nested under the directory.
- targetExclude(project.layout.buildDirectory)
+ targetExclude(project.layout.buildDirectory.asFileTree)However, I believe that spotless could do that automatically, if the type is known to represent a directory.
On another note I tried to pass a Provider<String> (targetExclude(genDirectory.map { it.asFile.path + "/**/*.scala" })), but this was interpreted as a single file (because the value is passed to project.files(...)).