Commenting out maven module restores code coverage for several other modules.

32 views
Skip to first unread message

the.rob...@gmail.com

unread,
Jun 4, 2020, 8:52:37 PM6/4/20
to JaCoCo and EclEmma Users
Desired Outcome

Our maven project generates 2 applications/war files. The binary jacoc.exec is uploaded to SonarQube.

A Simplified structure looks like:

Parent (pom)
App1 (pom)
app1-common (jar) 
app1-core (jar)
app1-webapp(war) - Contains java code
 
App2 (pom)
app2-common(jar)
app2-core(jar)
app2-webapp(war) - Contains no java code 
 
We expect to see code and coverage for all maven modules that contain java code but noticed that code and coverage information was entirely missing
app2-common(jar)
app2-core(jar)



We searched through the jacoco.exec file to verify that none of the classes were present, just to make sure.

If in the App2 aggregate pom we remove the app2-webapp module :

Parent (pom)
App1 (pom)
app1-common (jar) 
app1-core (jar)
app1-webapp(war) - Contains java code
App2 (pom)
app2-common(jar)
app2-core(jar)
 
the code coverage for 
app2-common
app2-core
 
is displayed as expected.

In the app2-webapp pom we tried adding
<properties>
<jacoco.skip>true<jacoco.skip>
<maven.test.skip>true</maven.test.skip> 
</properties>

We also  tried changing app2-webapp(war)  to app2-webapp(jar)  
Removing  all of the maven plugins from app2-webapp
 and limiting the dependencies to only 
app2-common(jar)
app2-core(jar)

but still the code coverage for 
app2-common(jar)
app2-core(jar)
Is missing.

Environment: Jenkins CentOS 7 and Oracle Java 8u151 , Jacoco 0.8.5 uploading to SonarQube 7.X

I have also tried using jacoco 0.7.9 with the same results.
 
 Does anyone know what I am missing ? 
 
 
                                     

Marc Hoffmann

unread,
Jun 8, 2020, 8:59:29 AM6/8/20
to jac...@googlegroups.com
Hi,

how are you creating code coverage reports? Note that the prepare-agent and report goals work in the scope of individual modules. So there should be a separate exec file and report in every module.

If you have a different setup please share a minimal reproducer so we can understand what exactly you’re doing.

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/7dfb7294-8f79-4751-8c37-449dad009167o%40googlegroups.com.

the.rob...@gmail.com

unread,
Jun 8, 2020, 10:26:56 AM6/8/20
to JaCoCo and EclEmma Users
We are appending the jacoco.exe files. The settings are defined in the top level parent pom.

    <plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<configuration>
<destFile>${sonar.jacoco.reportPaths}</destFile>
<append>true</append>
</configuration>
<executions>
<execution>
<id>agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<phase>test</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

We build with full debug: lines,vars,source
We were experimenting with the XML format but we haven't worked out the kinks yet.


We actually have 5 applications,2 wars , 3 schedules deployed as zip files, over 58 poms, and this is  only project that is displaying issues.
I'll work on creating a GitHub project that reproduces this issue.

Thanks for your time.
To unsubscribe from this group and stop receiving emails from it, send an email to jac...@googlegroups.com.

Marc Hoffmann

unread,
Jun 8, 2020, 11:01:43 AM6/8/20
to jac...@googlegroups.com

You’re using report-aggregate. This goal requires as separate module for the report. Please see documentation:


On the other hand if you use Sonar with exec files there is no need to create reports at all.

Regards,
-marc


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/dce20da3-57b8-4509-b749-9643b027ac73o%40googlegroups.com.

the.rob...@gmail.com

unread,
Jun 8, 2020, 8:01:45 PM6/8/20
to JaCoCo and EclEmma Users
As indicated we are using jacoco.exec for code coverage.
The Aggregate Reports XML reports I just added when debugging the missing code coverage issue and is as I stated is not working properly, probably for the reasons you pointed out.

I'll reply again when I have a MVP that reproduces this issue.

-Rob
 

On Monday, June 8, 2020 at 11:01:43 AM UTC-4, Marc R. Hoffmann wrote:

You’re using report-aggregate. This goal requires as separate module for the report. Please see documentation:


On the other hand if you use Sonar with exec files there is no need to create reports at all.

Regards,
-marc


the.rob...@gmail.com

unread,
Jun 18, 2020, 1:29:53 PM6/18/20
to JaCoCo and EclEmma Users
Just wanted to close the loop before contacting SonarQube.

The issue appears not to be in Jacoco but instead in SonarQube. In the failed scenario and the workaround scenario we discovered the appended jacoco.exec is exactly the same. 

Details

Even if a child pom uses a different groupId from its parent if the artifactid name is the same the code coverage will disappear for all child modules.

In app/pom.xml Changing

<parent>
	<groupId>org.free2create.jacoco.mvp.reports</groupId>
	<artifactId>app-reports</artifactId>
	<version>7776.0.0.0-SNAPSHOT</version>
	<relativePath>../</relativePath>
</parent>

<groupId>org.free2create.jacoco.mvp.app</groupId>
<artifactId>app-reports</artifactId>

To

<parent>
	<groupId>org.free2create.jacoco.mvp.reports</groupId>
	<artifactId>app-reports</artifactId>
	<version>7776.0.0.0-SNAPSHOT</version>
	<relativePath>../</relativePath>
</parent>

<groupId>org.free2create.jacoco.mvp.app</groupId>
<artifactId>app-reports-app</artifactId>

Works around the issue for the created demo code and in our real application.

Further Notes

The Issue appears in a 3 level pom but not a 2 level pom:

Can reproduce

Top level(pom)

    Middle (pom)

	core(pom)

	app(war)

Will not reproduce.

Top level(pom)

     core(pom)

     app(war)
Reply all
Reply to author
Forward
0 new messages