开发者

Why is Sonar design view not showing any dependencies for my project?

开发者 https://www.devze.com 2023-03-04 01:35 出处:网络
I\'ve successfully set up Sonar against a large Java project that is built using Ant. I\'ve finally hooked up the JUnit test results and the Cobertura code coverage report.

I've successfully set up Sonar against a large Java project that is built using Ant. I've finally hooked up the JUnit test results and the Cobertura code coverage report.

I now see all the packages in the design view but there are no values for dependencies between any of the packages or classes (see example below).

Why is Sonar design view not showing any dependencies for my project?

Does anyone have any idea what I have missed here?

UPDATE

Looking at the output of the Sonar Ant task I also notice that the package design task is completing very quickly for what is a fairly large and complicated project. From the Ant output:

[sonar:sonar] [INFO]  Package design analysis...
[sonar:sonar] [INFO]  Package design analysis done: 66 ms

The Ant task is as follows:

<target name="sonar" depends="collate-xml-reports">
    <sonar:sonar workDir="src/build/sonarTemp" key="myProjectKeyWhichHasBeenChangedToHideMyClient" version="1.0" xmlns:sonar="antlib:org.sonar.ant">

        <!-- source directories (required) -->
        <sources>
            <path location="src/common/src" />
            <path location="src/commonWidgets/src" />
            <path location="src/compositionWidget/src" />
            <path location="src/nativeLib/src" />
            <path location="src/services/src" />
        </sources>

        <!-- list of properties (optional) -->
        <property key="sonar.projectName" value="RPS Nightly" />
        <property key="sonar.dynamicAnalysis" value="reuseReports" />
        <property key="sonar.surefire.reportsPath" value="src/reports/junit" />
        <property key="sonar.cobertura.reportPath" value="src/reports/cobertura/coverage.xml" />

        <!-- test source directories (optional) -->
        <tests>
            <path location="src/common/test" />
            <path location="src/commonWidgets/test" />
            <path location="src/compositionWidget/test" />
            <path location="src/services/test" />
        </tests>

        <!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
        <binaries>
            <path location="src/common/build" />
            <path location="src/commonWidgets/build" />
            <path location="src/compositionWidget/build" />
            <path location="src/services/build" />
        </binaries>

        <!-- path to libraries (optional). These libraries are for example used by the Java Findbugs plugin -->
        <libraries>
            <path location="src/common/lib/**/" />
            <path location="src/commonWidgets/lib/**/" />
            <开发者_StackOverflow;path location="src/compositionWidget/lib/**/" />
            <path location="src/services/lib/" />
        </libraries>
    </sonar:sonar>
</target>


Being a Java n00b it turns out that this was a misunderstanding on my part. The binaries directory locations need to point to the root folder of the compiled Java bytecode but I was pointing it to the jar file location. In this case the bytecode is written to the build/classes folder so I needed to modify my ant target (shown in the question) from:

    <binaries>
        <path location="src/common/build" />
        <path location="src/commonWidgets/build" />
        <path location="src/compositionWidget/build" />
        <path location="src/services/build" />
    </binaries>

To:

    <binaries>
        <path location="src/common/build/classes" />
        <path location="src/commonWidgets/build/classes" />
        <path location="src/compositionWidget/build/classes" />
        <path location="src/services/build/classes" />
    </binaries>

This fixed the problem and the design view is now correctly populated.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号