and maven sonar:sonar goal


(Preetam Palwe) #1

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 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 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 present in project folder work with maven sonar:sonar goal???

Appreciate any help on this.

Many Thanks !

(G Ann Campbell) #2

Hi Preetam,

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

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.


(Preetam Palwe) #3

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 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 !