tarini sunil
tarini sunil

Reputation: 57

Need to exclude AspectJ closure classes from Jacoco coverage

We need to use AspectJ compile time weaving and that is creating the AjcClosure classes. Somehow the package weaving is not working for us. We need to exclude these AjcClosure classes from the coverage calculation in jacoco maven plugin as it has reduced the coverage to half.

We tried

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.5</version>
    <configuration>
        <excludes>
            <exclude>**/*Aspect*.*</exclude>
            <exclude>**/*AjcClosure*.*</exclude>
        </excludes>
    </configuration>
    <executions>
        <execution>
            <id>prepare-agent</id>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
        </execution>
    </executions>
</plugin>

However, it is not coming in the report but the coverage is still half. I will be really grateful if we can have a way out.

Upvotes: 1

Views: 399

Answers (1)

kriegaex
kriegaex

Reputation: 67297

From the AspectJ 1.9.19 release notes:

Improve condy (constant dynamic) support. Together with some custom compilation or weaving options, this helps to avoid a problem when using JaCoCo together with AspectJ, see this comment in #170 for more details.

Does using the latest AspectJ version and applying one of the two suggestions mentioned there solve your problem? Unfortunately, you neither explained what kind of problem you have exactly with AspectJ + JaCoCo nor provided a reproducer, which is a bad way to ask a question on Stack Overflow in the first place.

Upvotes: 0

Related Questions