I am trying to exclude Lombok coverage in Sonar.
This is my build.gradle:
plugins {
//...
id "org.sonarqube" version "4.0.0.2929"
id 'jacoco'
}
jacocoTestReport {
reports {
xml.enabled true
}
}
test.finalizedBy jacocoTestReport
//...
To exclude those classes I tried the following steps:
# This tells lombok this directory is the root,
# no need to look somewhere else for java code.
config.stopBubbling = true
# This will add the @lombok.Generated annotation
# to all the code generated by Lombok,
# so it can be excluded from coverage by jacoco.
lombok.addLombokGeneratedAnnotation = true
jacocoTestReport {
// ...
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: ['lombok/**'])
}))
}
}
gradlew.bat clean build test --debug sonar -Dsonar.projectKey=" + service + " -Dsonar.projectName=" + service + " -Dsonar.host.url=http://localhost:9000 -Dsonar.token=" + global_token
Unfortunately for some reason after executing the sonar task to analyze the project,
I still have the Lombok code uncovered:
lombok.config must be in the root of the project, not in src\main\resources