-1

I am new to Sonar. I have multi-module maven project. please find the Project structure below

-Parent
| -Module A
    |
     -pom.xml (Module A) 
| -Module B
    |
     -pom.xml (Module B)
| -Module C
|   |
|    -pom.xml (Module C)
|
--pom.xml (parent pom)   

Note : (Module C is shared module in Module A/ Module B - means Internally module C will the part of into Module A , Module B library) Based on the Project requirement we have these structure.

  1. Module A - works for external users.
  2. Module B - works for internalusers.
  3. Module C -common b/w both the module.

    I am trying to create single sonar report for both the module, but I am not able to integrate all the module junit report (Module A and Module B report) into single report.I followed couple of example to combine the muti-module maven porject but nothing works.

similar issue1 similar issue2
github-example (reference given in sonar)

Community
  • 1
  • 1
Imran khan
  • 819
  • 3
  • 12
  • 24
  • I don't get why you added jacoco-maven-plugin, sonarqube, maven-cobertura-plugin, sonarqube5.1, maven-plugin if your question is about junit... None of these tags match your question. – Kraal Oct 03 '15 at 20:30
  • @kraal : When you have multi-module project , In such case to cover the entire project coverage we have to merge the J-unit report with the help of extra plugin configuration. – Imran khan Oct 07 '15 at 06:15
  • There is no question in your post. You're only writing about your unability to "integrate all the module junit report". So what are you trying to do ? Edit your post in order to provide a clear question people can try to answer (instead of having to guess wht you're expecting) – Kraal Oct 07 '15 at 06:58
  • @kraal : I think you have not read this line "but I am not able to integrate all the module junit report (Module A and Module B report) into single report." – Imran khan Oct 07 '15 at 09:07

2 Answers2

0

I had similiar problem with over 40 modules which were even nested. What you have to do is to create whole sonar configuration in parent pom.

<sonar.host.url>set url here (default is localhost)</sonar.host.url>
<sonar.login>user for host url (default admin)</sonar.login>
<sonar.password>password for host url (default is admin)</sonar.password>
<sonar.projectName>optional name for whole project in sonar view</sonar.projectName>
<sonar.projectDescription>optional project description for sonar view</sonar.projectDescription>
<sonar.projectBaseDir>like name says you can set project base dir, if you have parent pom as a separate module then you can type ".." to set main directory with all modules</sonar.projectBaseDir>

Set properly all modules which will be analysed separately for the whole project:

<sonar.modules>module1, module2, module3</sonar.modules>

Configure each one of them properly:

<module1.sonar.projectName>module1</module1.sonar.projectName>
<module1.sonar.projectBaseDir>module1/</module1.sonar.projectBaseDir>
<module1.sonar.sources>optionally set sources to proper directory for example src/main/java</module1.sonar.sources>

<!-- similiar for other 2 projects -->

That way all junit reports will be used per module but it will be listed in single project with modules. That way you will be able to see reports per module and per whole single project.

It's a good practise to check results after adding every single module. In case of failure simply check error in console and fix the problem.

-1

I am able to achieve Integration test coverage using sonar with Jococo plugin. To run the Sonar in local, i was facing the issue with SCM error in sonar. Every time it was failing in the in sonar report creation. For resolving the issue in local you need to disable the SCM configuration in sonar. login in local sonar as Admin - admin/admin (default username/password) Now under setting we have SCM tab - disable the SCM Senor and save the SCM Setting.

sonar setting window

Now in Dashboard --> Configure widgets .Search "Integration Tests Coverage"

enter image description here

Now add widget into your Project Dashboard.

enter image description here

Follow the same configuration in your pom.xml as given in the link.

https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/java/code-coverage/combined%20ut-it/combined-ut-it-multimodule-maven-jacoco

Imran khan
  • 819
  • 3
  • 12
  • 24