DEPRECATED - use SonarLint for local code analysis!
The plugin applies SonarQube configuration and tasks to projects according our best practices at welt.
See plugin portal.
The plugin applies only conventions and best practices. Thus you have to configure the sonarqube in your project as well.
Example:
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath(
'org.sonarqube.gradle:gradle-sonarqube-plugin:1.0',
'gradle.plugin.de.weltn24:sonarqube-conventions:2.0.0'
)
}
}
apply plugin: 'org.sonarqube'
apply plugin: 'de.weltn24.sonarqube-conventions'
The plugin adds sonarqubePreview task to the project. This task can be used in order to execute the SonarQube analysis in preview mode - a full analysis without storing it's results in the database (see documentation for details).
We use this tasks locally before pushing code changes to Git and on our PR checker pipelines.
Key | Default value | Applied for tasks | Mandatory |
---|---|---|---|
sonar.projectName | ${project.rootProject.name} | sonarqube, sonarqubePreview | true |
sonar.sourceEncoding | UTF-8 | sonarqube, sonarqubePreview | true |
sonar.jacoco.itReportPath | ${project.buildDir}/jacoco/integrationTest.exec | sonarqube | true |
sonar.host.url | sonarqube, sonarqubePreview | true | |
sonar.login | sonar | sonarqube, sonarqubePreview | true |
sonar.password* | sonarqube, sonarqubePreview | true | |
sonar.github.login | sonarqube | false | |
sonar.github.oauth | sonarqube | false | |
sonar.github.repository | sonarqube | false | |
sonar.github.pullRequest | sonarqube | false |
(*) the sonar.password property is the only property which must be set in order to successfuly apply the plugin at all.
All default values can be overwritten in the target project:
sonarqube {
properties {
// overriding properties in 'weltn24-sonarqube-conventions' plugin
property 'sonar.projectName', 'my-fancy-name'
// adding additional properties
property 'sonar.exclusions', 'src/main/resources/**'
}
}
Testing the functionality of the plugin during the development can be achieved manually by executing the following steps:
-
Publish your new changes to your local maven repository with
./gradlew publishToMavenLocal
(don't forget to increment the version number) -
Add the local Maven cache as a repository in an another gradle project than can integrate with the plugin:
buildscript { repositories { mavenLocal() } }
-
Use the updated version of the plugin as a local dependency with the gradle project from the step before and run the plugin.
Publishing is automatically done by SnapCI after a commit with increased version.
Contributions are more than welcome. Please follow the pull request pro tips in order to submit your changes.
Copyright (c) 2015 WeltN24 GmbH
Licensed under the MIT license.