Directory excluding in sonar-project.properties file doesn't work (for me)
Asked Answered
B

3

28

I have excluded the directory in my project properties but sonar doesn't exclude it. Can anyone help me to find problem?

sonar.sources=./ 
sonar.exclusions=./utility/Excel/**
Biliary answered 24/8, 2016 at 6:9 Comment(0)
B
48

I realized that first I should have written directory name Like below to exclude all folders and file on that directory:

 sonar.exclusions=utility/Excel/**/*

Second I should have used comma separated directory names to exclude more than one directory:

 sonar.exclusions=utility/Excel/**/* , utility/mailer/**/*
Biliary answered 29/8, 2016 at 5:5 Comment(3)
thanks for the comma separation information. It saved me a day.Kenlee
ok I just wanna throw out that it's really confusing sonar.sources uses path relative to sonar-project.properties, and apparently sonar.exclusions doesn't? ugh took me forever. thanks, never would have tried thatAlchemize
how to exclude multiple files?Hurter
H
37

Look at the Inclusions/Exclusions Patterns documentation , and try this: sonar.exclusions=utility/Excel/**.

Note: pointing sonar.sources to the current directory is usually a mistake, you should point it to the actual directories which contain the sources (more details in Analysis Parameters).

Hornmad answered 24/8, 2016 at 7:9 Comment(2)
This should be the accepted answer, not your own post answered 5 days later and explained stuff which wasn't even part of the question.Weitzel
The provided links are currently broken.Darky
P
0

If your exclusions still not work, double check the location of the file that you are trying to exclude. SonarQube automatically defines 2 scopes for analysis: sonar.sources and sonar.tests.

If the file that you want to exclude is inside sonar.tests scope, then you should use sonar.test.exclusions instead of sonar.exclusions

You can read more: here

Added for those who might need it

Parsonage answered 25/6, 2024 at 18:52 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.