3

我正在使用本地声纳 3.5.1 为我的 java maven 项目使用 mvn sonar:sonar 进行代码统计。但现在我想使用 sonar-runner 来做同样的事情。所以我安装了 sonar-runner 2.3 并设置在我的 Ubuntu $PATH 变量中,现在可以使用 sonar-runner -h 进行测试。我在项目的根目录中添加了 sonar-project.properties。这个文件的内容就像

# required metadata
sonar.projectKey=netsgear:analytix
sonar.projectName=analytix
sonar.projectVersion=1.0

# optional description
sonar.projectDescription=application analysis

# path to source directories (required)
sonar.sources=srcDir1,srcDir2

# The value of the property must be the key of the language.
sonar.language=java

# Encoding of the source code
sonar.sourceEncoding=UTF-8

# Additional parameters
sonar.my.property=value

声纳在 localhost://9000 上运行。但是从我的项目目录中执行我的“sonar-runner”它会抛出异常,sonar-runner -X 的输出是

INFO: SonarQube Server 3.5.1
13:06:50.497 ERROR rojectReactorBuilder - Invalid value of sonar.sources for 
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 0.483s
Final Memory: 3M/119M
INFO: ------------------------------------------------------------------------
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:90)
    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:41)
Caused by: java.lang.IllegalStateException: The folder 'srcDir1' does not exist for  (base directory = /home/workspace/core)
    at org.sonar.runner.batch.ProjectReactorBuilder.checkExistenceOfDirectories(ProjectReactorBuilder.java:475)
    at org.sonar.runner.batch.ProjectReactorBuilder.cleanAndCheckModuleProperties(ProjectReactorBuilder.java:370)
    at org.sonar.runner.batch.ProjectReactorBuilder.cleanAndCheckProjectDefinitions(ProjectReactorBuilder.java:353)
    at org.sonar.runner.batch.ProjectReactorBuilder.build(ProjectReactorBuilder.java:130)
    at org.sonar.runner.batch.IsolatedLauncher.createBatch(IsolatedLauncher.java:60)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
    ... 9 more

我可以知道共振吗

4

1 回答 1

4

我猜你的配置有错误。

# path to source directories (required)
sonar.sources=srcDir1,srcDir2

srcDir1 和 srcDir2 真的是存放源文件的文件夹吗?您似乎从一些教程中复制了配置,却忘记插入正确的文件夹名称。

您也可以删除以下行,因为我认为您没有任何像这样命名的自定义声纳参数。

# Additional parameters
sonar.my.property=value
于 2013-08-08T07:55:31.727 回答