求教sonar ant task使用findbugs问题

coolge 发布于 2014/07/25 13:21
阅读 1K+
收藏 0

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

    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


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

加载中
0
逝水fox
逝水fox
我也是,规则改成 Sonar way with Findbugs之后,执行一直有问题,Sonar way正常
0
coolge
coolge
问题已经解决了, 加入<property name="sonar.junit.reportsPath" value="sonar" /> 配置即可
返回顶部
顶部