在我们的 Java Spring 项目中,我们广泛使用 Lombok 并使用 lombok gradle 插件。 我们还使用 Open API 插件进行代码生成。
当我从 Lombok 8.6 升级到 8.10(没有其他更改)时,我现在从 Gradle 收到此错误。
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':entity-client:generateEffectiveLombokConfig' (type 'LombokConfig').
- Gradle detected a problem with the following location: '/Users/fkelly/dev/platform2-entity/entity-client/build/openapi-source/src/main/java'.
Reason: Task ':entity-client:generateEffectiveLombokConfig' uses this output of task ':entity-client:generateClientCode' 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 ':entity-client:generateClientCode' as an input of ':entity-client:generateEffectiveLombokConfig'.
2. Declare an explicit dependency on ':entity-client:generateClientCode' from ':entity-client:generateEffectiveLombokConfig' using Task#dependsOn.
3. Declare an explicit dependency on ':entity-client:generateClientCode' from ':entity-client:generateEffectiveLombokConfig' using Task#mustRunAfter.
有什么想法/建议吗?
我在 Gradle 谷歌搜索后找到了一个解决方法,但我对此并不满意。
// Due to Gradle dependency error when upgrading from Lombok 8.6 to 8.10
// Based on solution https://discuss.gradle.org/t/implicit-dependency-among-tasks-but-the-tasks-do-not-exist/46127
tasks.configureEach {
if (name == "generateEffectiveLombokConfig") {
mustRunAfter(tasks.generateClientCode)
}
}
还有其他选择吗?也许更简洁一些?