求教sonar ant task使用findbugs问题

发布于 2021-11-28 02:38:48 字数 4254 浏览 847 评论 2

各位大虾,我的问题是这样的:

    sonarqube版本4.4-RC2

    我修改了sonar-examples/projects/languages/java/ant/java-ant-simple 下的build.xml,如下

<?xml version="1.0" encoding="UTF-8"?>
<project name="Simple Java Project analyzed with the Sonar Ant Task" default="all" basedir="." xmlns:sonar="antlib:org.sonar.ant">

        <!-- ========= Define the main properties of this project ========= -->
        <property name="src.dir" value="src" />
        <property name="build.dir" value="target" />
        <property name="classes.dir" value="${build.dir}/classes" />

        <property name="sonar.host.url" value="http://192.168.3.205:9001" />

        <!-- Define the Sonar properties -->
        <property name="sonar.projectKey" value="org.codehaus.sonar:example-java-ant" />
        <property name="sonar.projectName" value="Simple Java Project analyzed with the Sonar Ant Task" />
        <property name="sonar.projectVersion" value="1.0" />
        <property name="sonar.language" value="java" />
        <property name="sonar.sources" value="src" />
        <property name="sonar.binaries" value="target/classes" />
  
        <property name="sonar.working.directory" value="sonar" />
        <!--property name="sonar.surefire.reportsPath" value="sonar/build/surefire-reports/findbugs-result.xml" /-->
        <property name="sonar.sourceEncoding" value="UTF-8" />

        <!-- Add your basic Sonar configuration below: sonar.jdbc.url, sonar.jdbc.username, etc. properties -->
        <property name="sonar.jdbc.url" value="jdbc:mysql://localhost:3306/sonar?useUnicode=true&amp;characterEncoding=utf8" />
        <property name="sonar.jdbc.username" value="sonar" />
        <property name="sonar.jdbc.password" value="sonar" />

        <!-- ========= Define "regular" targets: clean, compile, ... ========= -->
        <target name="clean">
                <delete dir="${build.dir}" />
        </target>
        <target name="init">
                <mkdir dir="${build.dir}" />
                <mkdir dir="${classes.dir}" />
        </target>

        <target name="compile" depends="init">
                <javac srcdir="${src.dir}" destdir="${classes.dir}" fork="true" debug="true" includeAntRuntime="false" />
        </target>

        <!-- ========= Define Sonar target ========= -->
        <target name="sonar" depends="compile">
                <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
                        <!-- Update the following line, or put the "sonar-ant-task-*.jar" file in your "$HOME/.ant/lib" folder -->
                        <classpath path="/root/analyzers/sonar-ant-task-2.2.jar" />
                </taskdef>

                <!-- Execute Sonar -->
                <sonar:sonar />
        </target>

        <!-- ========= The main target "all" ========= -->
        <target name="all" depends="clean,compile,sonar" />

</project>


但是当我执行ant命令后,报如下警告,findbugs生成的result与SurefireSensor 去查找的目录不一致

[sonar:sonar] 13:29:49.785 INFO  - Findbugs output report: /root/sonar-examples/projects/languages/java/ant/java-ant-simple/sonar/findbugs-result.xml
[sonar:sonar] 13:29:53.552 INFO  - Execute Findbugs 2.0.3 done: 5975 ms
[sonar:sonar] 13:29:53.553 INFO  - Sensor FindbugsSensor done: 5978 ms
[sonar:sonar] 13:29:53.553 INFO  - Sensor SurefireSensor...
[sonar:sonar] 13:29:53.555 INFO  - parsing /root/sonar-examples/projects/languages/java/ant/java-ant-simple/sonar/build/surefire-reports
[sonar:sonar] 13:29:53.556 WARN  - Reports path not found: /root/sonar-examples/projects/languages/java/ant/java-ant-simple/sonar/build/surefire-reports
[sonar:sonar] 13:29:53.556 INFO  - Sensor SurefireSensor done: 3 ms


    我在网上找了半天没找到解决方案, 希望高人指点我一下,可以通过配置来解决吗,小弟在此先谢过

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

秉烛思 2021-11-28 18:01:06

问题已经解决了, 加入<property name="sonar.junit.reportsPath" value="sonar" /> 配置即可

等你爱我 2021-11-28 16:53:33

我也是,规则改成
Sonar way with Findbugs之后,执行一直有问题,Sonar way正常

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文