Not able to read sonar-project.properties using maven sonar:sonar goal

I am trying to run a maven project to pick all properties from sonar-project.properties files instead passing as argument to maven command, below command works:
$mvn clean verify sonar:sonar -Dsonar.host.url=${sonar} -Dsonar.login=${sonar_token} …*
or works by defining sonar properties in pom.xml
or also works by using sonar scanner plugin.

But I have compulsion to use sonar-maven-plugin plugin due to some dependency issues. While defining sonar-project.properties file in root directory with all arguments as properties inside it and running:
$mvn clean verify sonar:sonar**
doesn’t pick properties from sonar-project.properties file.
Can somebody suggest or guide how can we achieve this, to get all properties from sonar properties files while running maven command.
Thanks in advance !

Hi @Vinod_Kumar2 ,

Welcome to SonarSource community! :sonarsource:

Maven projects cannot use sonar-project.properties. You need to define the properties directly in the pom.xml's <properties></properties> node like so, using the sonar.* pattern similar to the parameters in sonar-project.properties or apply them at the command line like system properties with -Dsonar.*:

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
    <aggregate.report.dir>tests/target/site/jacoco-aggregate/jacoco.xml</aggregate.report.dir>
    <sonar.exclusions>module1/**</sonar.exclusions>
  </properties>

Hi @Joe,

Thanks for your reply, really appreciate.

As I mentioned in my detail, I have compulsion to use sonar-maven-plugin plugin due to some dependency issues.
Is there is any workaround or way so that i can use this approach.
$mvn clean verify sonar:sonar**
and able to pick properties from sonar-project.properties file.

Any workaround or approach to pick properties from sonar-project.properties file while running maven build.

Regards,
Vinod

Hi @Vinod_Kumar2 ,

No, you will have to insert your sonar properties in the pom.xml, which can be used with sonar-maven-plugin. If that doesn’t work, can you show logs showing the error?

Regards,
Joe