Jacoco.exec for maven multimodule project is not

Hi,

Refering to this unanswered post:

I have tried this:

and this:

and many more and none was working.

It is important to note that I have tried it on a regular ( not multimodule ) maven project and it import works fine.

I ran with --debug and I could see the following:

INFO] 17:29:07.901 -------------  Scan myproj
[INFO] 17:29:07.904 Base dir: /repo/eraonel/git/myproj
[INFO] 17:29:07.904 Working dir: /repo/eraonel/git/myproj/target/sonar
[INFO] 17:29:07.905 Source paths: pom.xml
[INFO] 17:29:07.905 Source encoding: UTF-8, default locale: en_US
[DEBUG] 17:29:07.919 Declared extensions of language JSP were converted to sonar.lang.patterns.jsp : **/*.jsp
[DEBUG] 17:29:07.919 Declared extensions of language Java were converted to sonar.lang.patterns.java : **/*.java,**/*.jav
[INFO] 17:29:07.919 Language is forced to java
[DEBUG] 17:29:07.920 Initializers : 
[INFO] 17:29:07.920 Index files
[WARNING] 17:29:07.921 File '/repo/eraonel/git/myproj/pom.xml' is ignored because it doesn't belong to the forced language 'java'
[INFO] 17:29:07.921 0 files indexed
[DEBUG] 17:29:07.937 'jsp' skipped because there is no related file in current project
[DEBUG] 17:29:07.937 'FindBugs Sensor' skipped because there is no related file in current project
[DEBUG] 17:29:07.937 'Import of Checkstyle issues' skipped because there is no related file in current project
[DEBUG] 17:29:07.937 'Import of PMD issues' skipped because one of the required properties is missing
[DEBUG] 17:29:07.937 'Import of SpotBugs issues' skipped because there is no related file in current project
[DEBUG] 17:29:07.937 'SurefireSensor' skipped because there is no related file in current project
[DEBUG] 17:29:07.937 'JaCoCoSensor' skipped because there is no related file in current project
[DEBUG] 17:29:07.937 'JavaSquidSensor' skipped because there is no related file in current project
[DEBUG] 17:29:07.943 'jsp' skipped because there is no related file in current project
[DEBUG] 17:29:07.969 'Import of Checkstyle issues' skipped because one of the required properties is missing
[DEBUG] 17:29:07.969 'Import of PMD issues' skipped because one of the required properties is missing
[DEBUG] 17:29:07.980 'Import of SpotBugs issues' skipped because one of the required properties is missing
[DEBUG] 17:29:08.004 Sensors : JaCoCo XML Report Importer -> SonarJavaXmlFileSensor

I guess JaCoCoSensor is the plugin reading jacoco.exec but here it fails for some reason.

//mikael

Hi,

First of all IMO creation of new threads duplicating/related to your previous unanswered threads each two days

is not at all a good behavior in open community and is not a best way to get attention of its members.


Nevertheless given the provided information from these threads, I would advice you to read following answer:

which IMO explains pretty well how JaCoCoSensor in Java SonarQube Plugin collects jacoco.exec files specified by sonar.jacoco.reportPath property and associates them with code in case of multi-module Maven projects.

And additionally to pay attention that JaCoCo XML Report Importer refers to another sensor - to recently released GitHub - SonarSource/sonar-jacoco: SonarQube JaCoCo Plugin that instead of exec files reads XML file(s) specified by sonar.coverage.jacoco.xmlReportPaths. But the rest of mechanics remain the same - SonarQube performs analysis of one module after another, during which one sensor reads XML file(s) and another sensor reads exec file(s) specified in corresponding property of corresponding module, and associates coverage data from these file(s) with source files in this module.


If all the above doesn’t help, and given that

while this works for others, I would highly advise you to reconsider approach and instead of questions provide complete example of project and its configuration to clearly demonstrate your difficulty. Because unlikely that someone can blindly correctly guess what is wrong based on the information that you provide so far. And here is example of how concrete complete examples are useful and helpful - No Coverage despite unit tests on an open source project - #2 by Godin

Regards,
Evgeny

1 Like

Hi @Godin
Sorry about posting so many times.:blush:
I guess it was frustration over not receiving any replies and googling did not show an example that worked for me.
Reading that so many people had problems with this did not make it easier…

Anyhow I checked what is in the eclemma project and tried to apply it to our project.
I executed:

mvn -B clean install
mvn --debug -P sonar4 sonar:sonar

sonar4 profile contains address to sonar server.

I will get a jacoco.exec under parent folder:

rw-r--r--  1 myuser users 2725932 Oct 11 13:50 jacoco.exec
drwxr-xr-x  3 myuser users    4096 Oct 11 14:27 sonar

And in sonar directory:

-rw-r--r-- 1 myuser users    0 Oct 11 14:18 .sonar_lock
-rw-r--r-- 1 myuser users    0 Oct 11 14:27 class-mapping.csv
drwxr-xr-x 2 myuser users 8192 Oct 11 14:27 scanner-report

I attached my files,

  1. parent pom.xml ( but as text since it is what I can upload).pom.txt (29.8 KB)

  2. log from sonar:
    sonar_jacoco_mje.txt (3.5 MB)

I hope this gives a clue to what happens.

br,

//mikael

No:

Log doesn’t tell what you was expecting.

Log says that analysis was successful and that jacoco.exec file was processed:

[INFO] 14:21:01.801 Analysing /repo/eraonel/git/mje/resource-manager/../target/jacoco.exec
[INFO] 14:21:21.776 Analysing /repo/eraonel/git/mje/msran-jcat-extension-g2temp/../target/jacoco.exec
[INFO] 14:23:44.741 Analysing /repo/eraonel/git/mje/msran-jcat-extension-helpers/../target/jacoco.exec
[INFO] 14:26:51.266 Analysing /repo/eraonel/git/mje/msran-jcat-extension-actions/../target/jacoco.exec
[INFO] 14:27:33.562 Analysing /repo/eraonel/git/mje/msran-regression-tests/../target/jacoco.exec
[INFO] 14:27:47.912 Analysing /repo/eraonel/git/mje/rmemu-engine/../target/jacoco.exec

And seems that exactly as was specified in pom.xml:

<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>

How this is different from your expectations?

And this is clearly not a complete example which someone except you can execute. While e.g. EclEmma is complete example - even you can execute it.

Hi @Godin

I was expecting results to be pushed to sonar but it is not. So nothing at all is pushed to sonar.

As said before when running this for a non-multimodule project I get the following in log:

[DEBUG] 08:34:28.999 Upload report
[DEBUG] 08:34:29.128 POST 200 http://10.220.250.130/sonar/api/ce/submit?projectKey=anotherProject&projectName=Custom%20Rules | time=127ms
[INFO] 08:34:29.130 Analysis report uploaded in 131ms
[INFO] 08:34:29.132 ANALYSIS SUCCESSFUL, you can browse http://10.220.250.130/sonar/dashboard/index/anotherProject
[INFO] 08:34:29.132 Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] 08:34:29.132 More about the report processing at http://10.220.250.130/sonar/api/ce/task?id=AWZSYlMjOTyY5R0Eu58t
[DEBUG] 08:34:29.133 Report metadata written to /repo/eraonel/git/anotherProject/target/sonar/report-task.txt
[DEBUG] 08:34:29.136 Post-jobs : 
[INFO] 08:34:29.150 Task total time: 13.295 s

So why is the data not pushed for a multimodule project?

I hope I am a bit more clear.

br,

//mikael

Because for this particular analysis you do not perform full analysis:

[INFO] 14:18:41.655 Issues mode
[WARNING] 14:18:41.655 The use of the issues mode (sonar.analysis.mode=issues) is deprecated. This mode will be dropped in the futu
re.
1 Like

@Godin So what mode shall I use to get this working? Or maybe @ganncamp knows. And why did it work for a non-modular maven project with the same command for doing the analysis?