为什么 Sonar 设计视图没有显示我的项目的任何依赖项?
我已经针对使用 Ant 构建的大型 Java 项目成功设置了 Sonar。我终于连接了 JUnit 测试结果和 Cobertura 代码覆盖率报告。
我现在在设计视图中看到了所有包,但任何包或类之间都没有依赖关系的值(请参见下面的示例)。
有谁知道我在这里错过了什么?
更新
查看 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>
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).
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/**/" />
<path location="src/compositionWidget/lib/**/" />
<path location="src/services/lib/" />
</libraries>
</sonar:sonar>
</target>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为一名 Java 高手,事实证明这是我的一个误解。二进制文件目录位置需要指向已编译的 Java 字节码的根文件夹,但我将其指向 jar 文件位置。在这种情况下,字节码被写入 build/classes 文件夹,因此我需要将我的 ant 目标(如问题中所示)从: 修改
为:
这解决了问题,并且设计视图现在已正确填充。
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:
To:
This fixed the problem and the design view is now correctly populated.