0

当我使用声纳 findbug 进行代码审查时,它会抛出异常,声称缺少某些类。

经过一番研究,很明显,构建项目所需的 jars 应该包含在 pom.xml 中以供声纳使用。

为此,sonar官网建议,添加依赖,com.opensymphony xwork-core 2.1.6 system ${basedir}/.../xwork-core.jar

但是,对我来说,它总是不起作用。

我用的是windows,有没有大神赐教,怎么配置,尤其是systempath?

这是项目的一个模块的 pom.xml。

<project xmlns="http://maven.apache.org/POM/4.0.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>数据库</groupId>
  <artifactId>项目1</artifactId>
  <name>项目1</name>
  <版本>1.0</版本>
  <依赖项>
    <依赖>
        <groupId>com.opensymphony</groupId>
        <artifactId>xwork-core</artifactId>
        <version>2.1.6</version><!--安装到.m2文件夹,本地仓库,然后参考-->
    </依赖>
    <依赖>  
      <groupId>dep</groupId>
      <artifactId>dep1</artifactId>
      <version>1.0</version> <scope>系统</scope>
    <systemPath>${basedir}/lib//asn.jar</systemPath>    
    </依赖>  
  </依赖>
  <构建>
        <sourceDirectory>src</sourceDirectory>
        <outputDirectory>构建到/类</outputDirectory>
        <插件>
           <插件>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <配置>
                  <translation>1.5</translation>
                  <目标>1.5</目标>
                  <不包括>
                      <exclude>**/*.*</exclude>
                  </排除>
              </配置>
           </插件>
        </插件>
  </build>
  <属性>
    <sonar.dynamicAnalysis>假</sonar.dynamicAnalysis>
  </属性>
</项目>

谢谢,杰基

4

2 回答 2

1

您的项目是否已经是一个 maven 项目,或者您是否正在使用 ant 或其他工具编译东西,然后试图让声纳对其运行?对于非常复杂的项目,Sonar Light 模式可能会很棘手。如果您有一个多模块项目,我会在声纳的本地副本下获得最简单的项目,然后努力添加更多模块。

此外,我会尝试将文件本地复制到不从 ${basedir} 升级的不同目录。看看是否有帮助。所以 ${basedir}/lib/xwork-core.jar 类似的东西。

也许对于声纳分析,您可以有一个单独的任务将所需的库复制到可以适当访问的临时文件夹中,然后在分析完成后将其删除。

于 2010-12-27T19:20:53.527 回答
0

我发现了问题。声纳的官方文档实际上是错误的。“mvn sonar:sonar” 将调用 maven sonar 插件 2.0 beta,它不会启用库 jar 的依赖关系。相反,调用“mvn sonar3:sonar”,调用最新版本的 maven sonar 插件 2.4.1,可以正常工作。

于 2010-12-28T09:22:12.663 回答