Hi guys,
Sonarqube Server (Community Edition): 8.2.0.32929 or SonarCloud
Gradle : 6.3
Kotlin: 1.3.70
Groovy: 2.5.10
Ant: Apache Ant™ version 1.10.7 compiled on September 1 2019
JVM: 11.0.4 (Oracle Corporation 11.0.4+10-LTS)
OS: Windows 10 10.0 amd64
build.gradle.kts
plugins {
java
jacoco
id("org.sonarqube") version "2.8"
}
subprojects {
apply(plugin = "java")
apply(plugin = "jacoco")
sourceSets {
main {
java {
srcDir("main")
}
}
test {
java {
srcDir("test")
}
}
}
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.junit.jupiter", "junit-jupiter", "5.6.0")
}
tasks {
test {
useJUnitPlatform()
}
}
}
sonarqube {
properties {
property("sonar.projectKey", "samples")
property("sonar.host.url", "http://localhost:9000")
property("sonar.sourceEncoding", "UTF-8")
}
}
I have a couple of questions regarding SonarQube task as a part of sonarqube-gradle-plugin
. I’m trying to build a 3-stage (build/test/scan) CI pipeline for a multi-module Gradle/Java project. The Build stage - simply complies sources, Test - compiles tests, executes them and builds Jacoco coverage reports, and Scan runs SonarQube analysis. Because all necessary artifacts were prepared on the previous stages the SonarQube execution can look like: /gradlew sonarqube -x test
Questions:
- With the
-x test
exclusion Gradle shows these two deprecation notes for each subproject analyzed by SonarQube:
The configuration :projectA:testCompileClasspath was resolved without accessing the project in a safe manner. This may happen when a configuration is resolved from a different project.
This behavior has been deprecated and is scheduled to be removed in Gradle 7.0.
The configuration :projectA:compileClasspath was resolved without accessing the project in a safe manner. This may happen when a configuration is resolved from a different project.
This behavior has been deprecated and is scheduled to be removed in Gradle 7.0.
Could you advise the proper way to run only the SonarQube scan without performing extra steps? Technically, it looks like the -x test
does exactly what I need, but the huge number of build deprecations (885 subprojects x 2 = 1770 warnings) in the console looks scary to me.
- I had the expectation that running SonarQube analysis on a number of independent subprojects (no relations between them) can be done in parallel. Fortunately, Gradle provides
--parallel
option for this which works perfectly on Build and Test stages speeding up the process in times.
But, applying it to SonarQuby as./gradlew --parallel sonarqube
doesn’t give any benefits. Which I assume could make sense because there is only one root project SonarQube task running and it could be completed by a single thread. Is there something I can do to run the Sonar scanner in parallel to speed up the process?
I looked at the Performance guide for large project analysis but didn’t find any specific advice there.
Thank you!