Hi team, I come across this sample <Aggregating co...
# community-support
t
Hi team, I come across this sample Aggregating code coverage with JaCoCo from an application/distribution (Incubating) Sample . I downloaded the Groovy DSL and run successfully in my local. I would like to exclude
java/org/gradle/sample/utilities/JoinUtils.java
from my aggregated jacoco report. How do I do that?
v
Why do you want to do that? And really only from the aggregated one, or also from the individual ones?
t
Hi @Vampire I have a multi module project similar to this sample, and I would like to know how to exclude some classes, but I don't know how. So if you can show my how to exclude java/org/gradle/sample/utilities/JoinUtils.java in this sample. I will apply the same to my project.
I'm appreciated if you can show me both, from aggregated one and also individual one.
v
I asked why you want to exclude those classes. Are they for example generated classes and that's the reason you don't want them in the coverage report?
t
Some are generated classes, some are just pojo
v
For generated classes it is easy. Just make sure they have an annotation that has simple name
Generated
with at least class file retention, then JaCoCo automatically excludes them.
For arbitrary classes it is not so easy, there is no real proper support for excludes, just hacky ways to filter the class directories property: https://github.com/gradle/gradle/issues/20026 https://github.com/gradle/gradle/issues/14760 https://github.com/gradle/gradle/issues/13013
If I were you, I would make sure the generated classes are annotated properly and just keep the POJOs in the report. If they are not covered, they are not covered. If you want to increase their coverage, test them. There is imho no real reason to exclude them just because they are "just" POJOs. 🙂
t
My generated classes is in directory src-gen [main]
Do you mean that I should rename this directory to
Generated
?
v
No, I said the class needs to have an annotation with simple name
Generated
and at least class retention
Copy code
@Generated
public class AccessDeniedException { ... }
t
Got it, thank you!
👌 1