# Sonar-project.properties and maven sonar:sonar goal

**URL:** <https://community.sonarsource.com/t/sonar-project-properties-and-maven-sonar-sonar-goal/3938>\
**Category:** SonarQube Server / Community Build\
**Tags:** maven, sonarqube\
**Created:** [November 2, 2018, 5:39pm UTC](https://community.sonarsource.com/t/sonar-project-properties-and-maven-sonar-sonar-goal/3938 "2018-11-02T17:39:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![preetampalwe](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@preetampalwe](https://community.sonarsource.com/u/preetampalwe)\
**Post date:** [November 2, 2018, 5:39pm UTC](https://community.sonarsource.com/t/sonar-project-properties-and-maven-sonar-sonar-goal/3938/1 "2018-11-02T17:39:20Z")

</div>

Hi  
I am scanning code using sonar:sonar maven goal.  
I have to exclude certain files from sonar scannig. I can do this using property sonar.exclusions. (e.g. sonar.exclusions= **/my-pkg/** /\*)

Now my questions are how can I pass property to sonar:sonar?  
I have following options  
a) use of -Dsonar.exclusions= **/my-pkg/** /\* while calling sonar:sonar  
b) use of \<sonar.exclusions\> **/my-pkg/** /_\</sonar.exclusions\> in pom.xml  
c) use of sonar-project.properties and specify sonar.exclusions= **/my-pkg/** /_ in it.

I know a) and b) above works. But I am keen to use option c) as it keeps sonar config consolidated and isolated in separate file and dont clutter my pom.xml.  
Reading from documentation at [https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Maven](https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Maven) I am not sure whether options c) works?  
(I did tried it but has not worked for me - I am not sure if its my mistake or sonar:sonar does not support it?)

Thus my real question to community is does sonar-project.properties present in project folder work with maven sonar:sonar goal???

Appreciate any help on this.

Many Thanks !  
~Preetam

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [November 2, 2018, 5:43pm UTC](https://community.sonarsource.com/t/sonar-project-properties-and-maven-sonar-sonar-goal/3938/2 "2018-11-02T17:43:54Z")

</div>

Hi Preetam,

`mvn sonar:sonar` gets its configurations from the command line (with `-Dsonar.x=y` parameters) and the pom. It does not read `sonar-project.properties`.

I’d like to point out that you do have another option for setting these exclusions, which is via the UI, altho I recognize that that doesn’t get you any closer to your goal of “consolidated and isolated” configs.

&nbsp;  
HTH,  
Ann

---

<div class="post-metadata">

**Author:** ![preetampalwe](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@preetampalwe](https://community.sonarsource.com/u/preetampalwe)\
**Post date:** [November 2, 2018, 5:48pm UTC](https://community.sonarsource.com/t/sonar-project-properties-and-maven-sonar-sonar-goal/3938/3 "2018-11-02T17:48:33Z")

</div>

Thanks Ann

Yeah UI is also an option but as you said not suitable for my purpose.

BTW - Thanks for confirming that sonar:sonar does not read `sonar-project.properties`. I wont try to bother now why it has not worked for me.  
This also means I have to choose between -D or pom.xml options based upon my situation.

Anyway …  
Many Thanks !  
~Preetam
