How to use an gradle external property in sonar.properties

Hi All,
I have a multimodule project, for example:
sample-service
api-spec (module)
application (module)

I have gradle build. and I have sonar setup


sonar {
  properties {
    property "sonar.projectName", "Sample Service"
    ....... 
 }
}

and sonar-project.properties

sonar.modules=api-spec, application
api-spec.sonar.sources=....
.....
application.sonar.sources=...

all works great. But now I have 2 versions of the services in the same repo, For example

sample-service
 11 (version)
    api-spec (module)
    application (module)
12 (version)
   api-spec (module)
   application (module)

and I have the following property in gradle.properties

serviceVersion=11

now can i do something like this in sonar properties

sonar {
  properties {
    property "sonar.projectName", "Sample Service"
    property "sonar.serviceVersion", "\"${serviceVersion}"\"
    ....... 
 }
}

and in sonar-project.properties

sonar.modules=${serviceVersion}/api-spec, ${serviceVersion}/application
${serviceVersion}/api-spec.sonar.sources=....
.....
${serviceVersion}/application.sonar.sources=...

Is this possible? Need help to support this approach

Hey there.

If you’re using the SonarScanner for Gradle, you shouldn’t be using a sonar-project.properties file at all, and all the configuration will be in your build.gradle file.

How are you planning to use sonar.serviceVersion? This isn’t a built-in analysis parameter, and will have no effect on your analysis.