SonarQube 5.1.2无法识别sonar.sources

时间:2015-11-16 14:18:50

标签: sonarqube sonarqube5.1.2

以下是SonarQube分析的目录结构。

enter image description here

我正在使用带有C ++社区插件版本0.9.4的SonarQube 5.0和带有sonar-project.properties文件中提到的sonar.sources = .. / CheckoutDir1的sonar-runner 2.4。这就像一个魅力。

然后我升级到SonarQube 5.1.2,保持C ++社区插件,sonar-runner和sonar-project.properties文件不变。现在声纳运行器因以下错误而失败:

14:18:17.531 INFO  - Base dir: D:\CheckoutDir2
14:18:17.531 INFO  - Working dir: D:\CheckoutDir2\.sonar
14:18:17.531 INFO  - Source paths: ../CheckoutDir1
.
.
.
.

    ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
    at org.sonar.runner.api.Runner.execute(Runner.java:100)
    at org.sonar.runner.Main.executeTask(Main.java:70)
    at org.sonar.runner.Main.execute(Main.java:59)
    at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.NullPointerException
    at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:98)
    at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
    at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
    at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
    at sun.nio.fs.AbstractPath.resolve(AbstractPath.java:53)
    at org.sonar.api.batch.fs.internal.DefaultInputFile.path(DefaultInputFile.java:72)
    at org.sonar.api.batch.fs.internal.DefaultInputFile.file(DefaultInputFile.java:64)
    at org.sonar.api.batch.fs.internal.PathPattern$RelativePathPattern.match(PathPattern.java:101)
    at org.sonar.batch.scan.filesystem.LanguageDetection.isCandidateForLanguage(LanguageDetection.java:124)
    at org.sonar.batch.scan.filesystem.LanguageDetection.language(LanguageDetection.java:97)
    at org.sonar.batch.scan.filesystem.InputFileBuilder.completeAndComputeMetadata(InputFileBuilder.java:100)
    at org.sonar.batch.scan.filesystem.FileIndexer$1.call(FileIndexer.java:157)
    at org.sonar.batch.scan.filesystem.FileIndexer$1.call(FileIndexer.java:154)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

奇怪的是,sonar-runner中的调试参数-X,-e,-Dsonar.verbose = true显示除了java.lang.NullPointerException之外没有其他信息。

如果我提到sonar.sources的绝对路径,SonarQube分析工作正常。

请建议如何解决此问题?此外,SonarQube 5.1.2应该清楚地打印调试日志,关于无法从相对路径找到sonar.sources。

1 个答案:

答案 0 :(得分:0)

正如我在日志中看到的那样,声纳正在考虑将CheckoutDir2作为你的基础目录, 哪个不正确,

您应该设置sonar.projectBaseDir=<AbsolutePath>/ProjectName/CheckoutDir1然后sonar.sources=. 所以现在即使sonar-project.properties文件与源代码不在同一个目录中,它仍然会像它一样工作。