SonarQube Java
  1. SonarQube Java
  2. SONARJAVA-46

Jacoco only takes account of the first component specified in Sonar ANT Task

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: JaCoCo
    • Labels:
      None
    • Environment:
      N/A - same problem for Windows and Linux Systems
    • Number of attachments :
      1

      Description

      We use Sonar through the Sonar Ant Task (Version 1.2) to analyze our Java-based Client-/Server-Software. It consists of several Java projects (modules), and we analyze all modules as a whole with Sonar, to get the "Big Picture".

      We specify them to Sonar by giving the Ant task a list of all our Java projects including the binary, source and test folders with the means of the Ant properties "sonar.sources", "sonar.binaries" and "sonar.tests".

      This works pretty fine, except for Jacoco (IT) Coverage (Version 0.6), it only takes accout for the first module specified in the Ant properties mentioned before. This makes it useless for us, because we want coverage results of all modules and not only for the first one.

      If you need further information for tracking down this problem, please let me know.

      Thanks in advance for your help!!

      Best Regards,
      Reinhold

        Activity

        Hide
        Evgeny Mandrikov added a comment -

        Hi Reinhold,

        It would be really helpful, if you can provide an example project, which demonstrates your problem.

        Thanks.

        Show
        Evgeny Mandrikov added a comment - Hi Reinhold, It would be really helpful, if you can provide an example project, which demonstrates your problem. Thanks.
        Hide
        Reinhold Früsmer added a comment - - edited

        I prepared some small example, consisting of three Eclipse projects including dependencies, two of them contain Java sources and unit tests for simple Hello World examples, the third project named com.tts.build represents the build project and contains two simple Ant build scripts:

        build.project.xml: compiles and runs the test with Jacoco activated for the project specified as parameter 'project.dir'

        build.all.xml: triggers compilation and test runs for com.tts.project1 and com.tts.project2 by invoking build.project.xml, afterwards it merges Jacoco execution data and runs Sonar.

        Unfortunately, it's not quite the same result like with our production build, but the result seems to be near enough to reproduce the problem, I hope.

        Please pay attention to the unit test named Project1Test in com.tts.project1 - it is set to @Ignore … this will result in 0,0% IT Coverage in Sonar, but should be 50% since com.tts.project2.Project2Test was still executed.

        Maybe the first project specified in the Sonar Ant properties (sonar.binaries,sonar.sources,sonar.tests) , that does not provide any execution data will cause Jacoco Sonar Plugin to skip the rest of coverage analysis?!

        If I change the order of both projects specified by the Sonar Ant properties, then Sonar shows 100% IT coverage, but in this case it should be 50% again. It's the same as if I had executed Project1Test and ignored Project2Test.
        This makes me guess that only the first project specified in the Sonar Ant properties is evaluated for coverage.

        build.all.xml contains a 'reportHtml' target which is helpful to compare the results between Jacoco Ant Report and Jacoco Sonar Plugin.

        Please let me know if you need further information.

        Show
        Reinhold Früsmer added a comment - - edited I prepared some small example, consisting of three Eclipse projects including dependencies, two of them contain Java sources and unit tests for simple Hello World examples, the third project named com.tts.build represents the build project and contains two simple Ant build scripts: build.project.xml: compiles and runs the test with Jacoco activated for the project specified as parameter 'project.dir' build.all.xml: triggers compilation and test runs for com.tts.project1 and com.tts.project2 by invoking build.project.xml, afterwards it merges Jacoco execution data and runs Sonar. Unfortunately, it's not quite the same result like with our production build, but the result seems to be near enough to reproduce the problem, I hope. Please pay attention to the unit test named Project1Test in com.tts.project1 - it is set to @Ignore … this will result in 0,0% IT Coverage in Sonar, but should be 50% since com.tts.project2.Project2Test was still executed. Maybe the first project specified in the Sonar Ant properties (sonar.binaries,sonar.sources,sonar.tests) , that does not provide any execution data will cause Jacoco Sonar Plugin to skip the rest of coverage analysis?! If I change the order of both projects specified by the Sonar Ant properties, then Sonar shows 100% IT coverage, but in this case it should be 50% again. It's the same as if I had executed Project1Test and ignored Project2Test. This makes me guess that only the first project specified in the Sonar Ant properties is evaluated for coverage. build.all.xml contains a 'reportHtml' target which is helpful to compare the results between Jacoco Ant Report and Jacoco Sonar Plugin. Please let me know if you need further information.
        Hide
        Fabrice Bellingard added a comment - - edited

        Not sure this issue is still relevant with Sonar Ant Task 2.0. Reinhold, if you can make tests, feel free to tell us.

        Show
        Fabrice Bellingard added a comment - - edited Not sure this issue is still relevant with Sonar Ant Task 2.0. Reinhold, if you can make tests, feel free to tell us.
        Hide
        Reinhold Früsmer added a comment -

        With Sonar Ant Task 2.0, the problem is solved.

        Performed tests using:

        Show
        Reinhold Früsmer added a comment - With Sonar Ant Task 2.0, the problem is solved. Performed tests using: Sonar v.2.14 Sonar Ant Task 2.0 latest Jacoco distribution (0.6.2.201301041224) sample multimodule Ant project ( https://github.com/SonarSource/sonar-examples )

          People

          • Assignee:
            Freddy Mallet
            Reporter:
            Reinhold Früsmer
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: