How to do PR Sonar analysis file exclusion in my Spring Boot(Java) with Gradle

I have done analysis gradle build sonar for Spring Boot application, with sonar.exclusion=“src/main/mypackage/generated/**” and its working fine.

The challenge I’m getting is when create PR, this exclusion is not working. Those file are still analysed. How to go around it.?

Hey there

Importantly, this should be sonar.exclusions (note the s at the end).

Could it be as simple as that?

@Colin , my bad, that was typo. The (s) its there but it still analyse when creating Pull Request. How to go around it.?

Below is complete block for my spring boot app.

sonarqube {
        properties {
			property "sonar.projectKey", "api-mobile-adapter"
			property "sonar.projectName", "API : mobile-adapter"
            property "sonar.organization", "my-company"
            property "sonar.host.url", "https://sonarcloud.io"
            property "sonar.sourceEncoding", "UTF-8"
			property "sonar.exclusions", "src/main/java/com/mycompany/api/mobileadapter/generatedclients/**"
		}
    }

@Colin
Please, can you check my previous comment and advise.?

Sometimes you just have to be patient. :slight_smile:

Exclusions should work the same way in your PR analyses as they do in your main branch, assuming the exclusion is configured the same way and there’s been no major change in how your files are organized.

You can double check this by adding --info to your gradle sonar command.

Preprocessing files...
1 language detected in 2 preprocessed files
1 file ignored because of inclusion/exclusion patterns
...
Indexing files...
Project configuration:
  Excluded sources: **/build-wrapper-dump.json, **/test/**

Do you see any differences between your PR build and your main branch build?

This could be another redherring, but your original post listed the exclusion as:

But your most recent post

(different file path, generated vs generatedclients)

That’s why I recommend you check the logs to make sure you’re passing the same exclusion.