google / google/protobuf-gradle-plugin

'explodeCodeSourceDebug' uses this output of task 'generateDebugProto' without declaring an explicit or implicit dependency after Gradle update to 8.0.2

Open
#683 3 comments 4 reactions 0 assignees View on GitHub
Dominant language
Groovy
Stars
1.8k
Forks
288
PR merge metrics
No merged PRs in 30d

Description

We're experiencing the following error after updating gradle from `7.6.1` -> `8.0.2`
```
A problem was found with the configuration of task ':my-library:generateDebugProto' (type 'GenerateProtoTask').
- Gradle detected a problem with the following location: '/path/to/MyProject/my-library/build/generated/source/proto/debug'.

Reason: Task ':my-library:explodeCodeSourceDebug' uses this output of task ':my-library:generateDebugProto' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

Possible solutions:
1. Declare task ':my-library:generateDebugProto' as an input of ':my-library:explodeCodeSourceDebug'.
2. Declare an explicit dependency on ':my-library:generateDebugProto' from ':my-library:explodeCodeSourceDebug' using Task#dependsOn.
3. Declare an explicit dependency on ':my-library:generateDebugProto' from ':my-library:explodeCodeSourceDebug' using Task#mustRunAfter.

Please refer to https://docs.gradle.org/8.0.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
```

This appears like a misconfiguration at the plugin level, but not entirely sure.

We've added a workaround by adding the following to the affected module:
```groovy
afterEvaluate {
tasks.forEach {task ->
if (task.name.contains("explodeCodeSourceDebug")) {
task.dependsOn("generateDebugProto")
}
if (task.name.contains("explodeCodeSourceRelease")) {
task.dependsOn("generateReleaseProto")
}
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.