SonarQube 版本 9.2.4
SonarQube执行代码扫描失败,报错如下
remote: INFO: Sensor FindBugs Sensor [findbugs]
remote: INFO: Findbugs plugin version: 4.2.6
remote: INFO: JavaResourceLocator.binaryDirs() not available before SonarQube 9.8
remote: INFO: JavaResourceLocator.testClasspath() not available before SonarQube 9.8
remote: WARN: Findbugs needs sources to be compiled. Please build project before executing sonar or check the location of compiled classes to make it possible for Findbugs to analyse your (sub)project (/var/opt/gitlab/git-data/repositories/@hashed/d6/06/d6061bbee6cf13bd73765faaea7cdd0af1323e4b125342ac346047f7c4bda1fc.git/tmp).
remote: WARN: Property 'sonar.java.binaries' is not declared as multi-values/property set but was read using 'getStringArray' method. The SonarQube plugin declaring this property should be updated.
remote: INFO: ------------------------------------------------------------------------
remote: INFO: EXECUTION FAILURE
remote: INFO: ------------------------------------------------------------------------
remote: INFO: Total time: 14.870s
remote: INFO: Final Memory: 24M/296M
remote: INFO: ------------------------------------------------------------------------
remote: ERROR: Error during SonarScanner execution
remote: java.lang.IllegalStateException: Can not execute Findbugs
remote: at org.sonar.plugins.findbugs.FindbugsExecutor.execute(FindbugsExecutor.java:185)
remote: at org.sonar.plugins.findbugs.FindbugsSensor.execute(FindbugsSensor.java:130)
remote: at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
remote: at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
remote: at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
remote: at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
remote: at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
remote: at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:79)
remote: at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
remote: at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
remote: at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:384)
remote: at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:380)
remote: at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:349)
remote: at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
remote: at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
remote: at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:136)
remote: at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
remote: at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
remote: at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
remote: at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
remote: at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
remote: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
remote: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
remote: at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
remote: at java.base/java.lang.reflect.Method.invoke(Unknown Source)
remote: at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
remote: at com.sun.proxy.$Proxy0.execute(Unknown Source)
remote: at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
remote: at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
remote: at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
remote: at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
remote: at org.sonarsource.scanner.cli.Main.main(Main.java:62)
remote: Caused by: java.lang.IllegalStateException: One (sub)project contains Java source files that are not compiled (/var/opt/gitlab/git-data/repositories/@hashed/d6/06/d6061bbee6cf13bd73765faaea7cdd0af1323e4b125342ac346047f7c4bda1fc.git/tmp).
remote: sonar.java.binaries was set to ./
remote: Sonar JavaResourceLocator.classFilesToAnalyze was empty
remote: at org.sonar.plugins.findbugs.FindbugsConfiguration.buildMissingCompiledCodeException(FindbugsConfiguration.java:169)
remote: at org.sonar.plugins.findbugs.FindbugsConfiguration.initializeFindbugsProject(FindbugsConfiguration.java:139)
remote: at org.sonar.plugins.findbugs.FindbugsConfiguration.initializeFindbugsProject(FindbugsConfiguration.java:102)
remote: at org.sonar.plugins.findbugs.FindbugsExecutor.execute(FindbugsExecutor.java:114)
remote: ... 31 more
Findbugs分析的不是java源代码,而是编译后的class文件。
通过下图进行修改。