简体   繁体   中英

How to add sonarlint to gradle task?

Is it possible to add sonarlint to gradle task? If yes, how? My only idea till now is to download it manually in gradle script, but I suppose that there is a better solution.

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.4.1"
}

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

Yes there is. I assume that you have sonarlint installed on your system already. Here is the Gradle task that I am using to run it as a part of a Gradle Task:

task runSonarLint(type: Exec){
  dependsOn "assemble"
  workingDir 'src/main/java'
  executable "sonarlint.bat"
  args "-u"
}

Note: I am using some custom profiles from my SonarQube server and that is why I use the "-u" option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM