Adam Ahmed
02/23/2024, 4:28 PM./gradlew fastDetekt
just doesn’t seem to do anything. What am I missing here?
abstract class GitChangedFilesValueSource : ValueSource<List<String>, ValueSourceParameters.None> {
@get:Inject
abstract val execOperations: ExecOperations
override fun obtain(): List<String> {
val output = ByteArrayOutputStream()
execOperations.exec {
commandLine("git", "diff", "--name-only", "--diff-filter=ACM")
standardOutput = output
}
val result = String(output.toByteArray(), Charset.defaultCharset()).trim().split("\n")
println("GitChangedFilesValueSource invoked, changed files: $result") // this prints when I invoke the task
return result
}
}
// This is called in my Application convention plugin
internal fun Project.registerFastDetekt() {
val changedFiles = providers.of(GitChangedFilesValueSource::class) {}
tasks.register<Detekt>("fastDetekt") {
include(changedFiles.get())
doLast {
println("Changed files: ${changedFiles.get()}") // This never prints anything when I invoke the task!
}
}
}
gammax
02/23/2024, 4:34 PM--info
?Adam Ahmed
02/23/2024, 4:38 PMNO-SOURCE
which is kinda confusing because I also have this block defined elsewhere to configure tasks of the Detekt
type
tasks.withType<Detekt>().configureEach {
parallel = true
buildUponDefaultConfig = true
ignoreFailures = false
autoCorrect = target.hasProperty("detektAutoFix")
config.setFrom(files("$baseConfigFilePath/detekt.yml"))
baseline.set(file("$baseConfigFilePath/baseline.yml"))
setSource(file(layout.projectDirectory))
exclude(resourceFiles, buildFiles)
reports {
xml.required.set(false)
md.required.set(false)
}
}
Adam Ahmed
02/23/2024, 4:39 PMdetekt
itself works fine and it does fail when I have errors, but fastDetekt
evidently has no sourcesAdam Ahmed
02/23/2024, 4:40 PMfastDetekt
doesn’t change anything eitherAdam Ahmed
02/23/2024, 4:42 PMextensions.configure<DetektExtension> {}
as well. Does this mean that if I configure these settings in the Extension block, I don’t need to configure the Detekt
tasks? Because I think that didn’t work for me--would just like to confirm if my assumption is right/wrongAdam Ahmed
02/23/2024, 4:49 PM