Sineaggi / sonar-scanner-gradle

SonarQube Scanner for Gradle

Home Page:https://redirect.sonarsource.com/doc/gradle.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SonarScanner for Gradle

Build Status Quality Gate

User documentation

https://redirect.sonarsource.com/doc/gradle.html

Have Question or Feedback?

For support questions ("How do I?", "I got this error, why?", ...), please head to the SonarSource forum. There are chances that a question similar to yours has already been answered.

Be aware that this forum is a community, so the standard pleasantries ("Hi", "Thanks", ...) are expected. And if you don't get an answer to your thread, you should sit on your hands for at least three days before bumping it. Operators are not standing by. :-)

Contributing

If you would like to see a new feature, please create a new thread in the forum "Suggest new features".

Please be aware that we are not actively looking for feature contributions. The truth is that it's extremely difficult for someone outside SonarSource to comply with our roadmap and expectations. Therefore, we typically only accept minor cosmetic changes and typo fixes.

With that in mind, if you would like to submit a code contribution, please create a pull request for this repository. Please explain your motives to contribute this change: what problem you are trying to fix, what improvement you are trying to make.

Make sure that you follow our code style and all tests are passing (Travis build is executed for each pull request).

Developer documentation

How the plugin works

When the plugin is applied to a project, it will add to that project the Sonar task. It will also add to the project and all it's subprojects the Sonar extension. For multi-module projects, the plugin will only apply to the first project where it gets called. The goal is to allow the usage of allprojects {}, for example.

Sonar extension The sonar extension enables an easy configuration of a project with the Domain Specific Language.

Sonar task The Sonar task has the name sonar, so it can be executed by calling ./gradlew sonar. It collects information from the project and all its subprojects, generating the properties for the analysis. Then, it runs the SonarScanner analysis using all those properties. The task depends on all compile and test tasks of all projects (except for skipped projects). If all projects are skipped (by adding skipProject=true to the sonar DSL), the analysis won't execute.

Using the plugin directly in a project (no need to build/install it in advance)

A composite build can be used to substitute plugins by an included build.

In the target project, apply the sonarqube plugin:

plugins {
  id 'org.sonarqube'
}

Run with:

./gradlew sonar --include-build /path/to/sonar-scanner-gradle

Debugging the plugin

See the previous point about including the plugin's build when building a target project. To debug, simply add the parameter:

./gradlew sonar --include-build /path/to/sonar-scanner-gradle -Dorg.gradle.debug=true

Now debug remotely by connecting to the port 5005.

Install a SNAPSHOT in the local Maven repository

./gradlew publishToMavenLocal

Using the plugin SNAPSHOT previously installed in the local Maven repository

buildscript {
    repositories { 
      mavenCentral()
      mavenLocal()
    }
    dependencies { classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:<THE VERSION>' }
}

apply plugin: 'org.sonarqube'

Release and deploy on Gradle plugin repository

https://plugins.gradle.org/docs/publish-plugin

./gradlew release

License

Copyright 2011-2023 SonarSource.

Licensed under the GNU Lesser General Public License, Version 3.0)

About

SonarQube Scanner for Gradle

https://redirect.sonarsource.com/doc/gradle.html

License:GNU Lesser General Public License v3.0


Languages

Language:Java 81.6%Language:Groovy 17.5%Language:Dockerfile 0.5%Language:Shell 0.4%Language:Starlark 0.0%Language:JavaScript 0.0%