diff --git a/src/main/kotlin/build/buf/gradle/LintTask.kt b/src/main/kotlin/build/buf/gradle/LintTask.kt index b44422ff..3c7261d2 100644 --- a/src/main/kotlin/build/buf/gradle/LintTask.kt +++ b/src/main/kotlin/build/buf/gradle/LintTask.kt @@ -42,7 +42,7 @@ abstract class LintTask : AbstractBufExecTask() { fun bufLint() { execBufInSpecificDirectory( "lint", - if (v1SyntaxOnly.get() && !hasWorkspace.get()) { + if (noWorkspaceAndV1Syntax() || noWorkspaceAndNoProtobufGradlePlugin()) { bufConfigFile.orNull?.let { listOf("--config", it.readAndStripComments()) } } else { null @@ -55,6 +55,12 @@ abstract class LintTask : AbstractBufExecTask() { } } + private fun noWorkspaceAndV1Syntax() = + !hasWorkspace.get() && v1SyntaxOnly.get() + + private fun noWorkspaceAndNoProtobufGradlePlugin() = + !hasWorkspace.get() && !hasProtobufGradlePlugin.get() + private fun File.readAndStripComments() = lines(toPath()).use { lines -> lines.asSequence()