Skip to content

Commit

Permalink
update gradle config to ignore auto-generated file from sonar and JaCoCo
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaffter committed Apr 9, 2024
1 parent f77550d commit 9777763
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
28 changes: 28 additions & 0 deletions apps/openchallenges/challenge-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,41 @@ jacocoTestReport {
reports {
xml.required = true
}

afterEvaluate {
// A single star (*) selects files AND subdirectories.
// Exclude Java classes from the JaCoCo report. These files must be excluded from SonarCloud
// report separatedly (see SonarCloud config)
def autoGeneratedFiles = [
'**/api/*.*',
'**/configuration/EnumConverterConfiguration*.*',
'**/configuration/HomeController*.*',
'**/configuration/SpringDocConfiguration*.*',
'**/model/dto/**',
'**/RFC3339DateFormat.*'
]
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: autoGeneratedFiles
)
}))
}
}

sonar {
// A single star (*) only selects files, not subdirectories.
def autoGeneratedFiles = [
'**/api/*',
'**/configuration/EnumConverterConfiguration*.*',
'**/configuration/HomeController*.*',
'**/configuration/SpringDocConfiguration*.*',
'**/model/dto/**',
'**/RFC3339DateFormat.*'
]
properties {
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.organization", "sage-bionetworks")
property("sonar.projectKey", "${project.name}")
property("sonar.coverage.exclusions", autoGeneratedFiles.join(","))
// Include the pull request number (ignored if not set)
property("sonar.pullrequest.key", System.getenv('SONAR_PULL_REQUEST_NUMBER'))
}
Expand Down
1 change: 0 additions & 1 deletion apps/openchallenges/image-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ sonar {
property("sonar.organization", "sage-bionetworks")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.coverage.exclusions", autoGeneratedFiles.join(","))
// property("sonar.log.level", "DEBUG")
// Include the pull request number (ignored if not set)
property("sonar.pullrequest.key", System.getenv('SONAR_PULL_REQUEST_NUMBER'))
}
Expand Down

0 comments on commit 9777763

Please sign in to comment.