为什么Sonar设计视图没有显示我的项目的任何依赖项?

时间:2011-05-10 16:05:32

标签: java dependencies sonarqube

我已成功针对使用Ant构建的大型Java项目设置Sonar。我终于连接了JUnit测试结果和Cobertura代码覆盖率报告。

我现在看到设计视图中的所有包,但是没有任何包或类之间的依赖关系值(参见下面的示例)。

No dependencies

有没有人知道我在这里错过了什么?

更新

查看Sonar Ant任务的输出我还注意到,包设计任务很快就完成了一个相当大而复杂的项目。从Ant输出:

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

Ant任务如下:

<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/**/" />
            <path location="src/compositionWidget/lib/**/" />
            <path location="src/services/lib/" />
        </libraries>
    </sonar:sonar>
</target>

1 个答案:

答案 0 :(得分:1)

作为一个Java n00b,事实证明这是我的一个误解。二进制目录位置需要指向已编译的Java字节码的根文件夹,但我将其指向jar文件位置。在这种情况下,字节码被写入build / classes文件夹,所以我需要修改我的蚂蚁目标(在问题中显示):

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

要:

    <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>

这解决了问题,现在正确填充了设计视图。