sonar-maven-plugin会引发重复的资源错误

时间:2014-03-08 00:58:48

标签: scala maven sonarqube

我正在尝试构建和测试scala项目。我使用scala-test代替surefire。我一直收到这个重复的资源错误,但我不知道重复的资源位置和资源。我使用的命令是“maven test sonar:sonar”。这是输出,

INFO: SonarQube Server 3.7.4 
[INFO] [16:36:12.615] Load batch settings 
[INFO] [16:36:12.650] User cache: /Users/carolyn_cheng/.sonar/cache 
[INFO] [16:36:12.653] Install plugins 
[INFO] [16:36:13.069] Install JDBC driver 
[INFO] [16:36:13.074] Create JDBC datasource for jdbc:mysql://localhost:3306/sonar 
[INFO] [16:36:13.873] Initializing Hibernate 
[INFO] [16:36:15.527] Load project settings 
[INFO] [16:36:15.547] Apply project exclusions 
[INFO] [16:36:15.676]
-------------  Scan Orbit 
[INFO] [16:36:15.678] Load module settings 
[INFO] [16:36:15.790] Quality profile : [name=sonar,language=scala] 
[INFO] [16:36:15.801] Excluded tests:  
[INFO] [16:36:15.802]  
**/package-info.java 
[INFO] [16:36:15.829] Configure Maven plugins 
[INFO] [16:36:15.854] Compare to previous analysis (2014-03-03) 
[INFO] [16:36:15.862] Compare over 30 days (2014-02-05, analysis of 2014-02-26 13:57:06.0) [INFO] [16:36:15.869] Compare to previous version 
[INFO] [16:36:15.929] Base dir: /Users/carolyn_cheng/WorkSpace/Orbit 
[INFO] [16:36:15.929] Working dir: /Users/carolyn_cheng/WorkSpace/Orbit/target/sonar 
[INFO] [16:36:15.929] Source dirs: /Users/carolyn_cheng/WorkSpace/Orbit/src/main/java, /Users/carolyn_cheng/WorkSpace/Orbit/src/main/scala 
[INFO] [16:36:15.929] Test dirs: /Users/carolyn_cheng/WorkSpace/Orbit/src/test/java, /Users/carolyn_cheng/WorkSpace/Orbit/src/test/scala, /Users/carolyn_cheng/WorkSpace/Orbit/src/test/java/../scala 
[INFO] [16:36:15.929] Binary dirs: /Users/carolyn_cheng/WorkSpace/Orbit/target/classes 
[INFO] [16:36:15.929] Source encoding: UTF-8, default locale: en_US 
[INFO] [16:36:15.966] Sensor ScalaSourceImporterSensor... 
[ERROR] Duplicate source for resource: org.sonar.plugins.scala.language.ScalaFile@36961e51 [INFO]
------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO]
------------------------------------------------------------------------ 
[INFO] Total time: 48.765s 
[INFO] Finished at: Fri Mar 07 16:36:18 PST 2014 
[INFO] Final Memory: 61M/445M 
[INFO]
------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.codehaus.sonar:sonar-maven-plugin:3.7.4:sonar (default-cli) on project Orbit: Duplicate source for resource: org.sonar.plugins.scala.language.ScalaFile@36961e51 -> [Help 1] [ERROR] 

由于某些原因,我总是得到clover-report.xml文件,即使我目前没有使用三叶草。

请帮忙。

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题但是我通过声纳跑步者而不是通过Maven跑步,因为我们使用SBT。我将这些行添加到我的sonar-project.properties文件as described here

sonar.dynamicAnalysis=reuseReports
sonar.surefire.reportsPath=test-reports
sonar.core.codeCoveragePlugin=cobertura
sonar.java.coveragePlugin=cobertura
sonar.cobertura.reportPath=target/scala-[scala-version]/coverage-report/cobertura.xml

请注意,您需要放置scala版本,例如2.10,2.9其中说[scala-version]。这让分析开始,但对我来说它仍然被打破,因为我们正在使用String Interpolation。在Scala 2.10之前不支持这种情况,它会破坏Scala分析器。我开始更新包含在Maven POM中的jar,但是将插件移动到Scala 2.10并非易事,因为它使用了reflect.generic.ModifierFlags was removed after 2.9.3。这都是可以修复的,但我需要查看Scala源代码!如果您使用Scala 2.9,它可能适合您。