I was trying to run sonarscan for gradle multiproject. I have running the scan from local using the command gradle sonar –info. Only one module it has analyzed and publish the results to sonarqube server. For the other modules it was not analyzing.
I was getting error for some modules like
The folder ‘src/test/java’ does not exist for ‘’ (base directory = /jenkinsapp/workspace/1.0-app-maven-gradle/dft)
13:56:21 > Task :dft:sonar FAILED
So after that i commented the sonar.sources and soner.tests in the sonar property file and started sonar scan ….it worked but only for one module.
The configuration related to sonar plugin and sonar properties in build.gradle file has given below:
plugins {
// Declare the SonarQube plugin here but don't apply it automatically.
// This makes the plugin available to all subprojects using the same version,
// while allowing us to selectively apply it only to relevant modules (e.g., exclude 'bom' or root).
id 'org.sonarqube' version '7.0.1.6134' apply false
}
allprojects {
group = 'com.sai.qgt'
version = '1.0.0.0-SNAPSHOT'
repositories {
maven {
url = project.uri("http://8.8.8.8/repository/private")
allowInsecureProtocol = true
metadataSources {
mavenPom()
artifact()
ignoreGradleMetadataRedirection()
}
}
}
}
subprojects {
if (project.name != 'bom') {
apply plugin: 'java-library' // apply Java plugin to all submodules by default
apply plugin: 'maven-publish'
apply plugin: 'jacoco'
apply plugin: 'org.sonarqube'
sonar {
properties {
property "sonar.host.url", "https://sonar.sai.com"
property "sonar.projectKey", "sai.qgt.app-gradle"
property "sonar.projectName", "sai-qgt.app-gradle"
property "sonar.token", "sai_12345672abcdef50a62"
//property "sonar.sources", "src/main/java"
//property "sonar.tests", "src/test/java"
// Add other required properties here
}
}
Let me know any other details. Need to provide. Thanks