2011-10-26 6 views
2

おはようございます、私はソーナーのcoberturaレポートの統合に関する質問があります。 私は2つの方法を試しました:hudsonから、そしてantタスクから。 私はソナーの統合を構成するためにハドソンを使用した場合、Coberturaのレポートは私のCoberturaのレポートがうまく統合されて、よく私のソナーのダッシュボードに統合されているが、私はカバレッジレポートのソナー・アリ・タスクまたはハドソンの統合

Java bytecode scan... 
[WARN] Class 'javax/mail/Folder' is not accessible through the ClassLoader. 
[WARN] Class 'javax/mail/Folder' is not accessible through the ClassLoader. 
[WARN] Class 'javax/mail/Folder' is not accessible through the ClassLoader. 
[WARN] Class 'javax/mail/Folder' is not accessible through the ClassLoader. 
[WARN] Class 'com/sun/mail/imap/IMAPFolder' is not accessible through the ClassLoader. 

しかし、のようないくつかの警告を持っている:

[INFO] Sensor CoberturaSensor... 
[INFO] parsing C:\hudson\jobs\Client Mail\workspace\cobertura\reports\coverage.xml 
[INFO] Sensor CoberturaSensor done: 1218 ms 

だから、私は私librairiesを管理できるように、Antタスクを使用することを決定し、これは私のantタスクです:

<target name="sonar" depends="cover-report"> 
<!-- The workDir directory is used by Sonar to store temporary files --> 
<sonar:sonar workDir="./" key="fr.simscorps:client.mail" version="0.1-SNAPSHOT" xmlns:sonar="antlib:org.sonar.ant"> 
<property key="sonar.host.url" value="http://172.30.3.55:1234/sonar/" /> 
    <!-- source directories (required) --> 
    <sources> 
    <path location="./src" /> 
    </sources> 

    <!-- list of properties (optional) --> 
    <property key="sonar.dynamicAnalysis" value="reuseReports" /> 
    <property key="sonar.projectName" value="client mail" /> 
    <property key="sonar.java.source" value="1.5" /> 
    <property key="sonar.projectVersion" value="0.1-SNAPSHOT" /> 
    <property key="sonar.phase" value="generate-sources"/> 
    <property key="sonar.cobertura.reportsPath" value="${reports.xml.dir}/coverage.xml"/> 
    <property key="sonar.surefire.reportsPath" value="${reports.xml.dir}/TESTS-test.TestSuiteClientMail.xml" /> 



    <!-- test source directories (optional) --> 
    <tests> 
    <path location="./test" /> 
    </tests> 

    <!-- binaries directories, which contain for example the compiled Java bytecode (optional) --> 
    <binaries> 
    <path location="./bin" /> 
    </binaries> 

    <!-- path to libraries (optional). These libraries are for example used by the Java Findbugs plugin --> 
    <libraries> 
    <path location="./lib/activation.jar" /> 
    <path location="./lib/deltasync.jar" /> 
    <path location="./lib/jaybird_full_2_1_6.jar" /> 
    <path location="./lib/junit.jar" /> 
    <path location="./lib/mail.jar" /> 
    <path location="./lib/libdeltasync/apache-mime4j-0.5.jar"/> 
    <path location="./lib/libdeltasync/commons-codec-1.5.jar"/> 
    <path location="./lib/libdeltasync/commons-codec-1.5-javadoc.jar"/> 
    <path location="./lib/libdeltasync/commons-codec-1.5-sources.jar"/> 
    <path location="./lib/libdeltasync/commons-logging-1.1.1.jar"/> 
    <path location="./lib/libdeltasync/httpclient-4.1.1.jar"/> 
    <path location="./lib/libdeltasync/httpclient-cache-4.1.1.jar"/> 
    <path location="./lib/libdeltasync/httpcore-4.1.jar"/> 
    <path location="./lib/libdeltasync/httpmime-4.1.1.jar"/> 
    <path location="./lib/libdeltasync/logback-classic-0.9.29.jar"/> 
    <path location="./lib/libdeltasync/logback-classic-0.9.29-sources.jar"/> 
    <path location="./lib/libdeltasync/logback-core-0.9.29.jar"/> 
    <path location="./lib/libdeltasync/logback-core-0.9.29-sources.jar"/> 
    <path location="./lib/libdeltasync/slf4j-api-1.6.1.jar"/> 
    <path location="./lib/libdeltasync/slf4j-api-1.6.1-sources.jar"/> 
    </libraries> 
</sonar:sonar> 
</target> 

私のレポートがうまく生成(約700ko)とハドソンのでています私はCoberturaのセンサーを参照してください、彼は何もしなかったみたいだログ:ここ

[sonar:sonar] [INFO] Sensor CoberturaSensor... 
[sonar:sonar] [INFO] Sensor CoberturaSensor done: 0 ms 

、私の他のantタスク依存:

<property name="junit.output.dir" value="junit"/> 
<property name="instrumented.dir" value="cobertura/instrumented"/> 
<property name="classes.dir" value="bin"/> 
<property name="jars.dir" value="lib"/> 
<property name="test.dir" value="test"/> 
<property name="cobertura.dir" value="${jars.dir}/cobertura"/> 
<property name="reports.xml.dir" value="cobertura/reports"/> 
<property name="cob.ser.file" value="cobertura.ser" /> 

<!-- Define the Sonar task if this hasn't been done in a common script --> 
    <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml"> 
    <classpath path="C:\hudson\tools\my_ant\lib" /> 
    </taskdef> 

<path id="cobertura.classpath"> 
    <fileset dir="${cobertura.dir}"> 
     <include name="cobertura.jar" /> 
     <include name="lib/**/*.jar" /> 
    </fileset> 
    <fileset dir="${jars.dir}"> 
     <include name="**/*.jar"/> 
    </fileset> 
</path> 

<taskdef classpathref="cobertura.classpath" resource="tasks.properties" /> 
<target name="clean" > 
    <delete dir="${instrumented.dir}" /> 
    <delete dir="${reports.xml.dir}" /> 
    <delete file="${cob.ser.file}" /> 
</target> 

<target name="prepare" depends="clean"> 
     <mkdir dir="${instrumented.dir}" /> 
     <mkdir dir="${reports.xml.dir}" /> 
</target> 
<target name="instrument" depends="prepare"> 
    <cobertura-instrument todir="${instrumented.dir}"> 
      <ignore regex="org.apache.log4j.*" /> 
      <fileset dir="${classes.dir}"> 
       <include name="**/*.class" /> 
       <exclude name="**/*Test.class" /> 
      </fileset> 

     </cobertura-instrument> 
</target> 



<target name="testsuite" depends="instrument"> 
    <junit fork="yes" dir="${test.dir}" failureProperty="test.failed" printsummary="withOutAndErr"> 
      <!-- 
       Specify the name of the coverage data file to use. 
       The value specified below is the default. 
      --> 
      <sysproperty key="net.sourceforge.cobertura.datafile" 
       file="${basedir}/cobertura.ser" /> 
      <!-- 
       Note the classpath order: instrumented classes are before the 
       original (uninstrumented) classes. This is important. 
      --> 
      <classpath location="${instrumented.dir}" /> 
      <classpath location="${classes.dir}" /> 

      <!-- 
       The instrumented classes reference classes used by the 
       Cobertura runtime, so Cobertura and its dependencies 
       must be on your classpath. 
      --> 
      <classpath refid="cobertura.classpath" /> 

      <formatter type="xml" /> 
      <test name="test.TestSuiteClientMail" todir="${reports.xml.dir}" /> 

      <!--<batchtest todir="${reports.xml.dir}" unless="testcase"> 
       <fileset dir="${test.dir}"> 
        <include name="**/*Test*.java" /> 
       </fileset> 
      </batchtest>--> 
     </junit> 
</target> 

<target name="cover-report" depends="testsuite"> 
    <cobertura-report format="xml" destdir="${reports.xml.dir}" srcdir="${test.dir}" /> 
</target> 

誰もがアイデアを持っていますか?

+0

は[OK]を、私のせいで、問題は、私が使用する構文である: それは です私たちは[こちら]見ることができるように なく <プロパティキー= "sonar.cobertura.reportsPath" 値= "$ {} reports.xml.dir /coverage.xml" /> [1]申し訳ありません [1]:http://docs.codehaus.org/display/SONAR/Advanced+parameters –

+0

これを回答として投稿したり(後で受け入れる)、質問を削除することができます(解決されているため)。 – oers

+0

はい、私は十分な評判スコアを得ていないので、私は自分の質問に答えることができる前に8時間待つ必要があります。私はこの夕方または朝の朝にやるでしょう。 –

答えて

1

[ANSWER] [OK]を、私のせいで、問題は、私が使用する構文である:それは

<property key="sonar.cobertura.reportPath" value="${reports.xml.dir}/coverage.xml"/> なく <property key="sonar.cobertura.reportsPath" value="${reports.xml.dir}/coverage.xml"/>だ、我々はあなたがクラスローダのエラーについてはhere申し訳ありません

1

を見ることができるように私のバイナリ&ライブラリのプロパティのパスが私のプロジェクトのルートから作成されていることを確認して、私は私の手を取り除きました。

<property name="sonar.libraries" value="./Module/resources/web/WEB-INF/lib" /> 

ではなく、クラスローダエラーを与える

<property name="sonar.libraries" value="resources/web/WEB-INF/lib" /> 

。これが誰かを助けることを望みます。それを理解するために私の数日間を取った!

関連する問題