2012-02-08 90 views
2

當我嘗試在項目的根目錄生成運行mvn sonar:sonar -e與錯誤掉落:聲納Maven的構建正在下降

[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'. 
[email protected][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: [email protected][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; charset = utf-8

有什麼建議嗎?

+0

我認爲該文件包含非UTF-8編碼字符。棘手的問題來診斷。 – 2012-02-08 22:22:12

回答

2

看起來像一個open issue與Sonar,由於在說,源和測試文件夾相同的PHP文件名引起的。該問題存在於java as well。根據this,這應該在下一個版本中修復。

可能的解決方法:

  • 如果你遇到這樣的問題,你可以嘗試重命名(如果可能) 測試文件,使分析失​​敗
+0

謝謝。我已經在測試中重命名了report.php文件,現在可以,現在測試中的另一個文件現在會導致錯誤:測試中的IndexControllerTest.php,主代碼中沒有這樣的文件。 錯誤回溯完全相同。 這次可能是什麼? – stalker2832 2012-02-09 12:55:48

+0

也許是因爲我的測試在同一個目錄下? 主要代碼在源代碼中,並且測試在源代碼/測試/ – stalker2832 2012-02-09 14:28:21

0

首先,都是你的源編碼在UTF-8? 如果是這樣,你有沒有嘗試刪除report.php源文件,只是爲了看看它是不是隻有這個類有問題?