What spotless must depend on?

230 Views Asked by At

I added diffplug/spotless plugin to my project placing it as a dependency of a build task.

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

I get the following error:

* 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.

So I started adding dependencies which was displayed in the error. The code passes gradlew clean build only after adding this horrible list:

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

Is that really necessary? Why spotlessJava has to depend on integrationTest? I would prefer to run spotless before integration tests.

1

There are 1 best solutions below

0
LancerX On

I had include '**/*.java' and now I added exclude '**/build/generated/**' to prevent spotless looking into generated code. Now the spotless task does not use the ouptput of eg. quarkusGenerateCodeDev. So the answer of @Simon Jacobs helped to some extent.