Jacocoプラグイン-jacoco.execによって生成されたカバレッジレポートを公開しようとしています。しかし、前述のソナーとJacocoの構成を除いて、以下の例外が発生します。
SonarCubeバージョン 6.7.7
[ERROR] Coverage report 'jacoco.exec' could not be read/imported. Error: {}
Java.lang.IllegalStateException: Failed to parse JaCoCo XML report: jacoco.exec
at org.sonar.plugins.jacoco.XmlReportParser.parse(XmlReportParser.Java:96)
at org.sonar.plugins.jacoco.JacocoSensor.importReport(JacocoSensor.Java:73)
at org.sonar.plugins.jacoco.JacocoSensor.importReports(JacocoSensor.Java:64)
at org.sonar.plugins.jacoco.JacocoSensor.execute(JacocoSensor.Java:48)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.Java:53)
at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.Java:88)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.Java:82)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.Java:68)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.Java:88)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.Java:177)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.Java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.Java:121)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.Java:291)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.Java:286)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.Java:264)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.Java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.Java:121)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.Java:48)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.Java:84)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.Java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.Java:121)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.Java:121)
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.Java:116)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.Java:71)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.Java:46)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:498)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.Java:60)
at com.Sun.proxy.$Proxy24.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.Java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.Java:138)
at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.Java:65)
at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.Java:104)
at org.Apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.Java:134)
at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:207)
at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:153)
at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:145)
at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:116)
at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:80)
at org.Apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.Java:51)
at org.Apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.Java:128)
at org.Apache.maven.DefaultMaven.doExecute(DefaultMaven.Java:307)
at org.Apache.maven.DefaultMaven.doExecute(DefaultMaven.Java:193)
at org.Apache.maven.DefaultMaven.execute(DefaultMaven.Java:106)
at org.Apache.maven.cli.MavenCli.execute(MavenCli.Java:863)
at org.Apache.maven.cli.MavenCli.doMain(MavenCli.Java:288)
at org.Apache.maven.cli.MavenCli.main(MavenCli.Java:199)
at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62)
at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
at Java.lang.reflect.Method.invoke(Method.Java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.Java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.Java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.Java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.Java:356)
Caused by: javax.xml.stream.XMLStreamException: Java.nio.charset.MalformedInputException: Input length = 1
at com.Sun.org.Apache.xerces.internal.impl.XMLStreamReaderImpl.setInputSource(XMLStreamReaderImpl.Java:212)
at com.Sun.org.Apache.xerces.internal.impl.XMLStreamReaderImpl.<init>(XMLStreamReaderImpl.Java:184)
at com.Sun.xml.internal.stream.XMLInputFactoryImpl.getXMLStreamReaderImpl(XMLInputFactoryImpl.Java:262)
at com.Sun.xml.internal.stream.XMLInputFactoryImpl.createXMLStreamReader(XMLInputFactoryImpl.Java:134)
at org.sonar.plugins.jacoco.XmlReportParser.parse(XmlReportParser.Java:46)
... 56 common frames omitted
Caused by: Java.nio.charset.MalformedInputException: Input length = 1
at Java.nio.charset.CoderResult.throwException(CoderResult.Java:281)
at Sun.nio.cs.StreamDecoder.implRead(StreamDecoder.Java:339)
at Sun.nio.cs.StreamDecoder.read(StreamDecoder.Java:178)
at Java.io.InputStreamReader.read(InputStreamReader.Java:184)
at Java.io.BufferedReader.fill(BufferedReader.Java:161)
at Java.io.BufferedReader.read1(BufferedReader.Java:212)
at Java.io.BufferedReader.read(BufferedReader.Java:286)
at com.Sun.org.Apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.Java:1895)
at com.Sun.org.Apache.xerces.internal.impl.XMLEntityScanner.arrangeCapacity(XMLEntityScanner.Java:1761)
at com.Sun.org.Apache.xerces.internal.impl.XMLEntityScanner.skipString(XMLEntityScanner.Java:1829)
at com.Sun.org.Apache.xerces.internal.impl.XMLDocumentScannerImpl$XMLDeclDriver.next(XMLDocumentScannerImpl.Java:749)
at com.Sun.org.Apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.Java:602)
at com.Sun.org.Apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.Java:112)
at com.Sun.org.Apache.xerces.internal.impl.XMLStreamReaderImpl.setInputSource(XMLStreamReaderImpl.Java:202)
... 60 common frames omitted
ソナー設定:mavenで言及されているソナープラグインの設定の詳細
<sonar.jacoco.reportPath>target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.language>Java</sonar.language>
<sonar.verbose>true</sonar.verbose>
<sonar.Java.source>8</sonar.Java.source>
Jacoco設定 Mavenで言及されているJacocoプラグインの設定の詳細
<org.jacoco.version>0.8.1</org.jacoco.version>
<profile>
<id>sonar-coverage</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.3.0.603</version>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jacoco</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${org.jacoco.version}</version>
<configuration>
<append>true</append>
</configuration>
<executions>
<execution>
<id>agent-for-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>agent-for-integration-test</id>
<phase>verify</phase>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
ソナーまたはジャココの設定が不足していますか?
Java.lang.IllegalStateException:JaCoCo XMLレポートの解析に失敗しました:jacoco.exec
...
原因:javax.xml.stream.XMLStreamException:Java.nio.charset.MalformedInputException:入力長= 1
このエラーは、XMLの解析時にサポートされていない文字が見つかり、ファイルがjacoco.exec
であることを示しています。これは、jacoco.exec
がxmlではなくバイナリであるためです。
さらに Sonarはjacoco.execのサポートを廃止しました 。
coverage-test-data-importing-jacoco-coverage-report-in-xml-format に従うことをお勧めします。上記のリンクから:
デフォルトでは、生成されたレポートはtarget/site/jacoco/jacoco.xml;に保存されます。この場所はsonar-jacocoプラグインによって自動的にチェックされるため、それ以上の構成は必要ありません。通常どおりmvn sonar:sonarを起動するだけで、レポートが取得されます。