web-dev-qa-db-ja.com

SonarQubeはJava 8をまだサポートしていますか?

Java 8、実行gradle sonarRunnerはこのエラーメッセージを表示します。 (sonarQubeバージョン:4.2.1)

Java.lang.ArrayIndexOutOfBoundsException: 26721
    at org.objectweb.asm.ClassReader.readClass(Unknown Source) [asm-all-3.2.jar:5.0_BETA]
    at org.objectweb.asm.ClassReader.accept(Unknown Source) [asm-all-3.2.jar:5.0_BETA]
    at org.objectweb.asm.ClassReader.accept(Unknown Source) [asm-all-3.2.jar:5.0_BETA]
    at org.sonar.Java.bytecode.asm.AsmClassProviderImpl.decoracteAsmClassFromBytecode(AsmClassProviderImpl.Java:76) [Java-squid-2.0.jar:na]
    at org.sonar.Java.bytecode.asm.AsmClassProviderImpl.getClass(AsmClassProviderImpl.Java:55) [Java-squid-2.0.jar:na]
    at org.sonar.Java.bytecode.asm.AsmClassVisitor.visit(AsmClassVisitor.Java:52) [Java-squid-2.0.jar:na]
    at org.objectweb.asm.ClassReader.accept(Unknown Source) [asm-all-3.2.jar:5.0_BETA]
    at org.objectweb.asm.ClassReader.accept(Unknown Source) [asm-all-3.2.jar:5.0_BETA]
```

SonarQubeはまだJava 8をサポートしていませんか?サポートが利用可能になる時期を知りたいのですが。

ありがとうございました。

11
xyzlast

SonarQube supports Java 8(2014年3月末から)(最初はいくつかの hickups でしたが、バージョン2.2で修正されましたJavaプラグイン)。

ソナーのアップデートセンターでPMDプラグインとCheckstyleプラグインの準備ができていないため、アンインストールする必要がありましたJava 8. Sonar独自のルールエンジンSquidは、これらのプラグインを冗長にする必要があります。


Gradle 1.11を使用してSonarを呼び出し、Jacocoにコードカバレッジを計算させたい場合は、Java 8バイトコードを分析するために、最新のJacocoバージョンを指定する必要があります。

gradle test jacocoTestReport sonarRunnerで呼び出されたときにそれを行う私のスクリプトは次のとおりです。

/** This script is responsible for unit testing and static analysis of the project source code*/

apply plugin: "jacoco"
apply plugin: "sonar-runner"

// Location of the XML unit test and code coverage reports 
def testResultsDir = "$buildDir/test-results/" // Use double quotes. Otherwise the $ won't work

jacoco{
    // Gradle 1.11 ships with a Jacoco version that doesn't support Java 8
    toolVersion = "0.7.0.201403182114"
}
// Call "gradle test jacocoTestReport" to produce a code coverage report at "build/reports/jacoco/test/html/index.html"
test {
    jacoco {
        def coverageReport = new File(testResultsDir, "jacocoTest.exec")
        destinationFile = file(coverageReport)
    }
}

// Let SonarQube analyze the project
sonarRunner {
    sonarProperties {
        property "sonar.projectKey", projectId
        property "sonar.projectName", projectName

        property "sonar.junit.reportsPath", testResultsDir

        // Address of SonarQube server
        property "sonar.Host.url", "http://localhost:9000"

        // SonarQube stores the test results in this database
        property "sonar.jdbc.url", "jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true"
        property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
        property "sonar.jdbc.username", "root"
        property "sonar.jdbc.password", sonarDBpassword
    }
}
12
Matthias Braun

あなたの質問には2つの側面があります:

  1. SonarRunner(クライアント)
  2. SonarQubeアプリケーション(サーバー)

受け取るエラーは、クライアントにダウンロードされ、古いバージョンのASM(3.2)に依存する Java Ecosystem プラグインから発生します。 AFAIK Java 8のサポートはバージョン5.0から始まります。FindbugsとJacocoでも同じ問題が発生します。 このディスカッション も参照してください。

SonarQubeサーバーについては起動できますが、「ウィジェットの設定」を選択するとクラッシュするので、いや、Java 8はまだサポートしていません。

4
tischda

間もなくサポートされます。 http://jira.codehaus.org/browse/SONARJAVA-386 を参照してください。