Gradle Error with processResources

OS: Windows 11
IDE: IntelliJ
Gradle Version: 7.0

After running gradle build command using gradle 7, i get following in the output

> Task :composition-protobuf:processResources
Execution optimizations have been disabled for task ':composition-protobuf:processResources' to ensure correctness due to the following reasons:
  - Gradle detected a problem with the following location: 'C:\workspace\exp-studio\es-backend\composition-protobuf\src\main\proto'. Reason: Task ':composition-protobuf:processResources' uses this output of task ':composition-protobuf:generateProto' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0/userguide/validation_problems.html#implicit_dependency for more details about this problem.
  - Gradle detected a problem with the following location: 'C:\workspace\exp-studio\es-backend\composition-protobuf\src\main\resources'. Reason: Task ':composition-protobuf:processResources' uses this output of task ':composition-protobuf:generateProto' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0/userguide/validation_problems.html#implicit_dependency for more details about this problem.
Gradle detected a problem with the following location: 'C:\workspace\exp-studio\es-backend\composition-protobuf\src\main\proto'. Reason: Task ':composition-protobuf:processResources' uses this output of task ':composition-protobuf:generateProto' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Gradle detected a problem with the following location: 'C:\workspace\exp-studio\es-backend\composition-protobuf\src\main\resources'. Reason: Task ':composition-protobuf:processResources' uses this output of task ':composition-protobuf:generateProto' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.

My build.gradle file looks like below:

plugins {
    id 'java'
    id "com.google.protobuf" version "0.8.17"
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.google.protobuf:protobuf-java:3.0.0'
    implementation group: 'io.grpc', name: 'grpc-all', version: '1.0.0'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'

}
sourceSets {
    main {
        java {
            srcDirs 'build/generated/source/proto/main/grpc'
            srcDirs 'build/generated/source/proto/main/java'
        }
    }
}
test {
    useJUnitPlatform()
}
protobuf {
    protoc {
        artifact = "com.google.protobuf:protoc:3.0.0"
    }
    plugins {
        grpc {
            artifact = 'io.grpc:protoc-gen-grpc-java:1.23.0'
        }
    }
    generatedFilesBaseDir = 'src'

    generateProtoTasks {
        all()*.plugins {
            grpc {}
        }
    }

}

What am i missing, with implicit dependency that is causing this issue.
In Gradle 7.0 this is a warning, and the build is successful.

Once i upgrade to Gradle 8.0 it becomes an error and the build breaks.
Please advice what needs to be added that i am missing.

Thank you.

I don’t know the protobuf plugin.
But from what you showed, I’d say you configure it to generate into <projectDir>/src which per-se is already an extremely bad idea.
The generateProto then probably declares <projectDir>/src as its output directory, which makes all files in that directory outputs of that task, which also is a very bad idea.
The processResources task then uses <projectDir>/src/main/proto and <projectDir>/src/main/resources as inputs, which are now considered output of generateProto.
But there is no dependency or odering constraint between those two tasks, which makes the build flaky and broken typically.

But as almost always with this error, the solution is not to add any dependencies or similar, but to fix wrong and overlapping outputs.

Configure the generation task to generate into some directory dedicated only to the outputs of that task, preferably withing layout.buildDirectory.
Then configure the task as srcDir for the main source set.
Not any manually configured directories like also used in your snippet, but really the task (assuming it properly declared its outputs, which it obviously did).

This then uses the tasks output as source files and thereby adding an implicit task dependency to all tasks that might need sources, including compile tasks, javadoc tasks, source jar tasks, …