gradle 一尘不染要靠什么?

xqk2d5yq  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(101)

我将diffplug/spotless插件添加到我的项目中,将其作为build任务的依赖项。

tasks.build.dependsOn(tasks.integrationTest, tasks.spotlessJava

字符串
我得到以下错误:

* What went wrong:
Some problems were found with the configuration of task ':spotlessJava' (type 'SpotlessTaskImpl').
  - Gradle detected a problem with the following location: 'C:\my-project'.

    Reason: Task ':spotlessJava' uses this output of task ':compileTestJava' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depe
nding on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':compileTestJava' as an input of ':spotlessJava'.
      2. Declare an explicit dependency on ':compileTestJava' from ':spotlessJava' using Task#dependsOn.
      3. Declare an explicit dependency on ':compileTestJava' from ':spotlessJava' using Task#mustRunAfter.


所以我开始添加依赖项,这在错误中显示。代码只在添加这个可怕的列表后才传递gradlew clean build

tasks.spotlessJava.dependsOn(tasks.quarkusGenerateCodeDev, tasks.quarkusGenerateCodeTests, tasks.processTestResources, tasks.quarkusBuild, tasks.integrationTest, tasks.prepareDeployment)


这真的有必要吗?为什么spotlessJava必须依赖于integrationTest?我宁愿在集成测试之前运行spotless。

ncgqoxb0

ncgqoxb01#

我有include '**/*.java',现在我添加了exclude '**/build/generated/**'来防止一尘不染地查看生成的代码。现在一尘不染的任务不使用例如quarkusGenerateCodeDev的输出。所以@Simon Jacobs的答案在一定程度上有所帮助。

相关问题