Search code examples
javagradlespotbugs

Spotbugs sequential execution as gradle task


I have a problem with running spotbugs as sequential gradle task. I want to mentioned that the project is Java multi module based. I am running parallel gradle tasks at once(up to 8 like compile,test,…) on different modules and I do not want to change that behavior. What I want is just one gradle task, in my case that task is spotbugs to run sequentially and the other tasks to run in parallel. Does gradle provides some option for that?

UPDATE: Use the Gradle feature called BuildService :) https://docs.gradle.org/current/userguide/build_services.html


Solution

  • To achieve what you want, you create a shared build service. This build service does not need to have any parameters and does not need to have any actual logic, it is only used for the sequencialising. You configure this build service to be used by maximum one task. And then you define all the tasks you want non-parallel to each other to use that service. This will cause only one of those tasks to run at the same time.