Exclude archive from analysis

27 views
Skip to first unread message

Mark Raynsford

unread,
Oct 17, 2024, 12:46:13 PM10/17/24
to jac...@googlegroups.com
Hello!

I'm running into an issue with the Jacoco Maven plugin.

I run the `report-aggregate` goal at the end of my builds to analyze
code and upload a coverage report in CI. This is the setup in the parent
pom that's shared across all projects:

https://github.com/io7m-com/primogenitor/blob/cd07a8034cf36bd9ac28480eaa01da08fc35ab4a/pom.xml#L954

Now, in one project, I have a test suite that contains what is
essentially a zip file containing Java class files. This zip file is a
file specimen that's used in the actual test code. It seems that the
Jacoco plugin is wandering into this zip file during reporting in CI and
causing the following error:

2024-10-16T20:01:52.1868147Z [ERROR] Failed to execute goal
org.jacoco:jacoco-maven-plugin:0.8.11:report-aggregate
(jacoco-report-merged) on project com.io7m.montarre.tests: An error has
occurred in JaCoCo Aggregate report generation. Error while creating
report: Error while analyzing
D:\a\montarre\montarre\com.io7m.montarre.tests\target\classes\com\io7m\montarre\tests\com.io7m.montarre.distribution-0.0.1-SNAPSHOT.mpk@LIB/LOGBACK-CORE-1.5.8.JAR@ch/qos/logback/core/util/ExecutorServiceUtil$1.class
with JaCoCo 0.8.11.202310140853/f33756c. Can't add different class with
same name: ch/qos/logback/core/util/ExecutorServiceUtil$1 -> [Help 1]

The actual project in question is here:

https://github.com/io7m-com/montarre

I'm not sure the CI build logs are visible to outsiders, though (they
probably aren't).

Is there some way to get the plugin to ignore these class files? If they
exist at all, they'll always be in a file with the suffix ".mpk", if
that helps at all.

--
Mark Raynsford | https://www.io7m.com

Marc Hoffmann

unread,
Oct 17, 2024, 12:54:49 PM10/17/24
to jac...@googlegroups.com
Hi,

indeed JaCoCo processes all class files and recursively all zip files by default. So if you’re *.mkp is in ZIP format it will be processed by JaCoCo.

The problem can probably be fixed by specifying an includes pattern **/*.class for the report-aggregate goal: https://www.jacoco.org/jacoco/trunk/doc/report-aggregate-mojo.html#includes

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/e7cd93f2-de94-4543-bcda-6d6af77bbe32%40io7m.com.

Mark Raynsford

unread,
Oct 17, 2024, 12:59:31 PM10/17/24
to jac...@googlegroups.com
On 17/10/2024 16:54, Marc Hoffmann wrote:
> Hi,
>
> indeed JaCoCo processes all class files and recursively all zip files by default. So if you’re *.mkp is in ZIP format it will be processed by JaCoCo.
>
> The problem can probably be fixed by specifying an includes pattern **/*.class for the report-aggregate goal: https://www.jacoco.org/jacoco/trunk/doc/report-aggregate-mojo.html#includes

Hello!

I did spot the include options in the documentation, but the problem is
that I don't know what the actual _class_ files will be called; I just
know that if they're in an `.mpk` archive, I shouldn't be looking at them.

What's the right kind of pattern to put into an include for this?

I feel like what I actually need is an _exclude_ pattern, and am
otherwise happy including everything.

Marc Hoffmann

unread,
Oct 17, 2024, 2:48:06 PM10/17/24
to jac...@googlegroups.com
With the **/*.class only the *.class files will be processed. The *.mpk file will be ignored. Wasn’t that your original request?
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/e22b2fd5-1ab0-441b-a8a6-81ddda8864c2%40io7m.com.

Mark Raynsford

unread,
Oct 17, 2024, 2:52:19 PM10/17/24
to jac...@googlegroups.com
On 17/10/2024 18:47, Marc Hoffmann wrote:
> With the **/*.class only the *.class files will be processed. The *.mpk file will be ignored. Wasn’t that your original request?
>

But wouldn't

"D:\a\montarre\montarre\com.io7m.montarre.tests\target\classes\com\io7m\montarre\tests\com.io7m.montarre.distribution-0.0.1-SNAPSHOT.mpk@LIB/LOGBACK-CORE-1.5.8.JAR@ch/qos/logback/core/util/ExecutorServiceUtil$1.class"

... Be matched by the pattern "**/*.class"?

I'm pretty sure that's true of inclusion patterns in other Maven plugins.

Marc Hoffmann

unread,
Oct 17, 2024, 4:06:17 PM10/17/24
to jac...@googlegroups.com
No. With the includes/excludes pattern the files which are processed are selected. Therefore com.io7m.montarre.distribution-0.0.1-SNAPSHOT.mpk and its content is not expected at all.
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/a3c19ee7-0f11-43a7-842a-7ac9e15adee4%40io7m.com.

Mark Raynsford

unread,
Oct 17, 2024, 5:29:09 PM10/17/24
to jac...@googlegroups.com
On 17/10/2024 20:06, Marc Hoffmann wrote:
> No. With the includes/excludes pattern the files which are processed are selected. Therefore com.io7m.montarre.distribution-0.0.1-SNAPSHOT.mpk and its content is not expected at all.

Thanks! The inclusion pattern seems to have worked.

Mark Raynsford

unread,
Oct 19, 2024, 5:07:15 PM10/19/24
to jac...@googlegroups.com
On 17/10/2024 21:26, Mark Raynsford wrote:
> On 17/10/2024 20:06, Marc Hoffmann wrote:
>> No. With the includes/excludes pattern the files which are processed are selected. Therefore com.io7m.montarre.distribution-0.0.1-SNAPSHOT.mpk and its content is not expected at all.
>
> Thanks! The inclusion pattern seems to have worked.
>

I spoke too soon.

Using this configuration:

https://github.com/io7m-com/primogenitor/blob/d837f8ab89656d4b4cf4141e5f6156b18fc292a6/pom.xml#L972

I'm now seeing 0% coverage in all projects.

Marc Hoffmann

unread,
Oct 20, 2024, 2:07:21 AM10/20/24
to jac...@googlegroups.com
This is because you also added it to the prepare-agent goal. Includes have a different semantic here, see documentation.

Please only add it to the goal report-aggregate.

> On 19. Oct 2024, at 23:07, Mark Raynsford <com.googleg...@io7m.com> wrote:
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/cbb01048-e9a7-49d3-9c80-f82b0878ff4a%40io7m.com.

Mark Raynsford

unread,
Oct 20, 2024, 5:48:23 AM10/20/24
to jac...@googlegroups.com
On 20/10/2024 06:07, Marc Hoffmann wrote:
> This is because you also added it to the prepare-agent goal. Includes have a different semantic here, see documentation.
>
> Please only add it to the goal report-aggregate.

Thanks, I'll give it a shot.

Not to be difficult, but... What am I missing here?

https://www.jacoco.org/jacoco/trunk/doc/report-aggregate-mojo.html#includes

"A list of class files to include in the report. May use wildcard
characters (* and ?). When not specified everything will be included."

https://www.jacoco.org/jacoco/trunk/doc/prepare-agent-mojo.html#includes

"A list of class names to include in instrumentation. May use wildcard
characters (* and ?). When not specified everything will be included."

Nothing about that screams different semantics to me...

Evgeny Mandrikov

unread,
Oct 20, 2024, 6:19:51 AM10/20/24
to jac...@googlegroups.com
“class files

vs

“class names


--
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.

Mark Raynsford

unread,
Oct 20, 2024, 6:35:01 AM10/20/24
to jac...@googlegroups.com
On 20/10/2024 10:19, Evgeny Mandrikov wrote:
> “class *files*“
>
> vs
>
> “class *names*”
>

Got it. Thanks!
Reply all
Reply to author
Forward
0 new messages