声纳maven构建正在下降

时间:2012-02-08 15:16:33

标签: php maven utf-8 sonarqube

当我尝试在项目中运行mvn sonar:sonar -e时,根目录构建正在下降并出现错误:

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Can not execute Sonar

Embedded error: Unable to read and import the source file : '/www/hudson/proj_beta/source/bin/report.php' with the charset : 'UTF-8'.
org.sonar.api.resources.File@10ade81[key=bin/report.php,dir=bin,filename=report.php,language=PHP]
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Can not execute Sonar
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Can not execute Sonar
        at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:103)
        at org.codehaus.mojo.sonar.Bootstraper.start(Bootstraper.java:79)
        at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:88)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        ... 17 more
Caused by: org.sonar.api.utils.SonarException: Unable to read and import the source file : '/www/hudson/c2c_beta/source/bin/report.php' with the charset : 'UTF-8'.
        at org.sonar.api.batch.AbstractSourceImporter.parseDirs(AbstractSourceImporter.java:84)
        at org.sonar.api.batch.AbstractSourceImporter.analyse(AbstractSourceImporter.java:69)
        at org.sonar.api.batch.AbstractSourceImporter.analyse(AbstractSourceImporter.java:60)
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:64)
        at org.sonar.batch.phases.Phases.execute(Phases.java:93)
        at org.sonar.batch.bootstrap.ProjectModule.doStart(ProjectModule.java:143)
        at org.sonar.batch.bootstrap.Module.start(Module.java:83)
        at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:111)
        at org.sonar.batch.bootstrap.BatchModule.doStart(BatchModule.java:101)
        at org.sonar.batch.bootstrap.Module.start(Module.java:83)
        at org.sonar.batch.bootstrap.BootstrapModule.doStart(BootstrapModule.java:102)
        at org.sonar.batch.bootstrap.Module.start(Module.java:83)
        at org.sonar.batch.Batch.execute(Batch.java:100)
        at org.sonar.maven.SonarMojo.executeBatch(SonarMojo.java:152)
        at org.sonar.maven.SonarMojo.execute(SonarMojo.java:142)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:98)
        ... 21 more
Caused by: org.sonar.api.resources.DuplicatedSourceException: org.sonar.api.resources.File@10ade81[key=bin/report.php,dir=bin,filename=report.php,language=PHP]
        at org.sonar.batch.index.SourcePersister.saveSource(SourcePersister.java:45)
        at org.sonar.batch.index.DefaultPersistenceManager.setSource(DefaultPersistenceManager.java:78)
        at org.sonar.batch.index.DefaultIndex.setSource(DefaultIndex.java:402)
        at org.sonar.batch.DefaultSensorContext.saveSource(DefaultSensorContext.java:159)
        at org.sonar.api.batch.AbstractSourceImporter.parseDirs(AbstractSourceImporter.java:81)
        ... 37 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 minutes 23 seconds
[INFO] Finished at: Wed Feb 08 14:50:49 EET 2012
[INFO] Final Memory: 16M/42M
[INFO] ------------------------------------------------------------------------

单元测试添加到源目录后开始下降。 谷歌搜索没有提供任何线索。

该文件位于utf-8:     report.php:text / plain;字符集= UTF-8

有什么建议吗?

2 个答案:

答案 0 :(得分:2)

看起来像是带有Sonar的open issue,由于源文件和测试文件夹中的相同php文件名而导致。 java as well存在此问题。根据{{​​3}},这应该在下一个版本中修复。

可能的解决方法:

  • 如果遇到此问题,可以尝试重命名(如果可能) 使分析失败的测试文件

答案 1 :(得分:0)

首先,你的所有资源都是用UTF-8编码的吗? 如果是这样,您是否尝试删除report.php源文件,只是为了查看这个类是否存在问题?