Correct way to handle excluded classes within a package

15,145 views
Skip to first unread message

John D. Ament

unread,
Apr 25, 2013, 9:52:54 AM4/25/13
to jac...@googlegroups.com
In my code, I have some classes that are coded and others that are code generated via JPA's metamodel gen.  When this gen runs, it places the generated classes in the same package.  I want to exclude these classes from code coverage reporting.  What is the proper way to ensure that they don't show in the reports?

Marc R. Hoffmann

unread,
Apr 29, 2013, 3:02:23 AM4/29/13
to jac...@googlegroups.com
Hi,

these classes must be excluded from report generation, here you have two
options: If the generated classes follow a common naming pattern you can
list the in the excludes attributes of the respective build tool you're
using. A cleaner way would be place the generated classes into a
different location and only supply the location of your app classes to
the reporting tool.

What build tool are you using to generate the report?

Best regards,
-marc
> --
> You received this message because you are subscribed to the Google
> Groups "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to jacoco+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>


John D. Ament

unread,
Apr 30, 2013, 7:31:34 AM4/30/13
to jac...@googlegroups.com
Hi & thanks for the response.

I'm using Maven.  I have this section:

<reporting>
<excludeDefaults>false</excludeDefaults>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.2.201302030002</version>
</plugin>

So what I did originally was:

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.2.201302030002</version>
<configuration>
<excludes>*_</excludes>
</configuration>
</plugin>

However they were still included.  I assumed this would ignore anything ending with a _.

Marc Hoffmann

unread,
Apr 30, 2013, 8:36:46 AM4/30/13
to jac...@googlegroups.com
Hi,

there are some known inconsistencies regarding includes/excludes:

https://github.com/jacoco/jacoco/issues/34

Basically for the Maven report goal the excludes refer to class file
names. So probably the pattern should be

<excludes>*_.class</excludes>

Best regards,
-marc
>> [1].
>>>
>>>
>
> --
> You received this message because you are subscribed to the Google
> Groups "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to jacoco+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out
> [2].
>
>
>
> Links:
> ------
> [1] https://groups.google.com/groups/opt_out
> [2] https://groups.google.com/groups/opt_out

John D. Ament

unread,
May 1, 2013, 10:07:13 AM5/1/13
to jac...@googlegroups.com
So, I tried that.  IT did help but the classes still show as 0%.  I don't want to show them at all.

Marc Hoffmann

unread,
May 1, 2013, 10:53:51 AM5/1/13
to jac...@googlegroups.com
> So, I tried that. IT did help but the classes still show as 0%.

Where does it show 0%? In the generated JaCoCo report?

Best regards,
-marc


On 2013-05-01 16:07, John D. Ament wrote:
> So, I tried that. IT did help but the classes still show as 0%. I
> don't want to show them at all.
>
> On Tuesday, April 30, 2013 8:36:46 AM UTC-4, Marc R. Hoffmann wrote:
>
>> Hi,
>>
>> there are some known inconsistencies regarding includes/excludes:
>>
>> https://github.com/jacoco/jacoco/issues/34 [1]
>> [2]
>>>> [1].
>>>>>
>>>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>
>>> Groups "JaCoCo and EclEmma Users" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>> send an email to jacoco+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out
>> [3]
>>> [2].
>>>
>>>
>>>
>>> Links:
>>> ------
>>> [1] https://groups.google.com/groups/opt_out [4]
>>> [2] https://groups.google.com/groups/opt_out [5]
>
> --
> You received this message because you are subscribed to the Google
> Groups "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to jacoco+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out
> [6].
>
>
>
> Links:
> ------
> [1] https://github.com/jacoco/jacoco/issues/34
> [2] https://groups.google.com/groups/opt_out
> [3] https://groups.google.com/groups/opt_out
> [4] https://groups.google.com/groups/opt_out
> [5] https://groups.google.com/groups/opt_out
> [6] https://groups.google.com/groups/opt_out

John D. Ament

unread,
May 4, 2013, 9:33:40 AM5/4/13
to jac...@googlegroups.com
Yes, this is the configuration I ended up adding (it's not clear if this parameter is supposed to be an array style like other excludes in maven, or a comma separated list):

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.2.201302030002</version>
<configuration>
<excludes>
<exclude>*_.class</exclude>
</excludes>
</configuration>
</plugin>

However in the report it still showed.  I would prefer that the class not show in the report.

John

iva...@gmail.com

unread,
May 20, 2015, 6:23:05 PM5/20/15
to jac...@googlegroups.com
Did anyone had solution for this. i want some of the generated sources need to be excluded from the report instead of showing as 0%

Evgeny Mandrikov

unread,
May 21, 2015, 4:56:53 AM5/21/15
to jac...@googlegroups.com, iva...@gmail.com, iva...@gmail.com
Please check https://github.com/jacoco/jacoco/tree/master/jacoco-maven-plugin.test/it/it-includes-excludes - files "FileUtil" and "TestUtil" are excluded from reports.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages