Issue with multi-project Gradle build
Using Gradle 6.5 and spotless version 4.3.0 on MacOS Mojave.
I have a multi project Gradle build with a root folder named Foo, a sub project named Foo, and another subproject named Foo-Implementation:
Foo -Foo -Foo-Implementation
When I run ./gradlew spotlessApply I get the following error:
`Execution failed for task ':config-audit:spotlessJavaApply'.
java.nio.file.NoSuchFileException: /Users/dalexander/Workspace/foo/foo/-Implementation/src/main/java/FooImplementation.java`
It's hard to notice but it's looking in folder 'foo/foo/-Implementation' instead of foo/foo-implemention. It's adding a '/' in between foo-implementation. I have no idea why it would be doing this. Project builds fine without spotless. Can anyone help?
we could help better with more context. copy-paste your build.gradles, along with info on whether this had worked in the past with a different version of Spotless or Gradle. Also the full stacktrace.
Closing due to inactivity, happy to reopen if more info comes forward.
Hello, I'm encountering a similar behavior after running spotlessApply and ktfmt. I have this file:
feature/some-feature/src/main/java/com/somecompany/someapp/feature/somefeature/ui/createpost/CreatePostFragment.kt
But spotless complains of not seeing this particular file:
feature/some-feature/some-feature/src/main/java/com/somecompany/someapp/feature/somefeature/ui/createpost/CreatePostFragment.kt
It is duplicating some-feature for some reason. It successfully formatted the file in question though.
I have version 6.22.0 set up, and my top-level build.gradle looks like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import io.gitlab.arturbosch.detekt.Detekt
buildscript {
ext.buildConfig = [
'compileSdk': 34,
'minSdk' : 21,
'targetSdk' : 34,
]
dependencies {
classpath libs.androidGradlePlugin
classpath libs.googleMobileServices
classpath libs.crashlyticsGradlePlugin
classpath libs.safeArgsPlugin
classpath libs.kotlinXSerializationPlugin
}
}
plugins {
alias(libs.plugins.kotlinAndroid) apply false
alias(libs.plugins.hilt) apply false
alias(libs.plugins.detekt)
alias(libs.plugins.spotless)
}
allprojects {
apply plugin: 'io.gitlab.arturbosch.detekt'
apply plugin: 'com.diffplug.spotless'
detekt {
config.setFrom("${rootProject.projectDir}/config/detekt/detekt.yml")
ignoreFailures = false
parallel = true
buildUponDefaultConfig = true
}
spotless {
kotlin {
target '**/*.kt'
targetExclude("**/build/**/*.kt", "**/test/**/*.kt")
ktfmt().kotlinlangStyle()
}
}
tasks.withType(Detekt).configureEach {
reports {
sarif.required.set(false)
html.required.set(true)
xml.required.set(false)
txt.required.set(false)
md.required.set(false)
}
}
}
dependencies {
detektPlugins(libs.detekt.formatting)
}
EDIT: It seems just specifying a single pattern in targetExclude fixes this behavior (i.e., just using targetExclude('**/build/**/*.kt')), but what if I want to exclude certain directories from spotless?