Can we overwrite pom.xml with cli?

In pom.xml some of the major files are being excluded from sonar scanning as below:


And we are scanning the sonar with this command:

sonar:sonar -Dsonar.projectName=lmno -Dsonar.language=java -Dsonar.sources=src/main/java -Dsonar.tests=src/test/java

we dont use, we give all properties as parameters to the cli command.

Can i override the changes in pom.xml through sonar cli command? If yes, how ?

Hey there.

You would just pass sonar.exclusions as an analysis parameter: mvn sonar:sonar -Dsonar.exclusions='**/abc/xyz.jav'

Thanks for the reply Colin but i think u misunderstand , when i say override, I dont want that file to be excluded from sonar scan, I want to include it.

I want that file to be included in the sonar scan even if its mentioned to be exclude in the pom.xml, I am asking if somehow i can nullify the sonar settings in pom.xml and include whatever is required from sonar-cli only.

You could, at that point, just set an empty or junk setting for sonar.exclusions on the command line, like mvn sonar:sonar -Dsonar.exclusions=

Tried this Colin, not working, the files mentioned in pom.xml to be excluded are still excluded and does not show the files in code section of project sonar dashboard.