Sonarlint Gradle Task

Hi,

I was wondering if it is possible to add SonarLint as a Gradle task and if so, if someone could provide an example?

The reason I am asking is that I want every developer in our team to be forced to run SonarLint when they run a Gradle build, rather than relying on them downloading the plugin and checking the IDE console in Intellij for the rules.

Thanks

Hello Mark,
Something is unclear for me here. You are talking about running sonarlint when building with gradle.
We have a tool named scanner for gradle for this.
SonarLint is designed so the issues do not arrive to the build step, they are fixed before. This tool should be used by the developers to fix issues on the fly.
The response to your question is then no, it is not possible to add SonarLint as a Gradle task.
Best regards,
Alexandre.

I had similar requirement. I don’t have SonarQube running nor SonarCloud solution, still I want to run SonarLint as part of the build process. Found the following gradle plugin

plugins {
  id "name.remal.sonarlint" version "1.0.189"
}

With it you can run SonarLint analysis whenever you build your gradle project with sonarlintMain task. You can find example of the usage on my blog.

And here is detailed pluign page

Hello, thanks for sharing your find! I guess that it can make sense for some setups.

On a personal note, I’m so used to the SonarLint + SonarQube combo that I find a bit odd to use the analyzers one a “one shot” basis like what the Gradle task offers. And I can also understand that it fills a sweet spot between the instant feedback from SonarLint in the IDE, and the longer term view of SonarQube :slight_smile: