1
Java and ANT versions:
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)

Apache Ant(TM) version 1.8.4 compiled on May 22 2012

Sonar version: 3.3.2

Sonar Ant Task version: 2.0, using sonar-ant-task-2.0.jar

运行构建脚本时出现以下错误。我也尝试在构建脚本中设置以下属性,但不断收到以下错误。请让我知道是否有人有任何解决方案。

sonar.sourceEncoding with value Windows-1252 

sonar.supportSourceFileDuplications with value as true

Error:

BUILD FAILED    

D:\TestProj\build-sonar.xml:40: org.sonar.api.utils.SonarException: Unable to read and import the source file : 'D:\TestProj\WEB-INF\src\com\iwf\ImageSearchCommand.java' with the charset : 'windows-1252'.
    at org.sonar.plugins.java.JavaSourceImporter.importSource(JavaSourceImporter.java:86)
    at org.sonar.plugins.java.JavaSourceImporter.parseDirs(JavaSourceImporter.java:70)
    at org.sonar.plugins.java.JavaSourceImporter.analyse(JavaSourceImporter.java:63)
    at org.sonar.plugins.java.JavaSourceImporter.analyse(JavaSourceImporter.java:59)
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:64)
    at org.sonar.batch.phases.Phases.execute(Phases.java:97)
    at org.sonar.batch.bootstrap.ProjectModule.doStart(ProjectModule.java:128)
    at org.sonar.batch.bootstrap.Module.start(Module.java:83)
    at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:114)
    at org.sonar.batch.bootstrap.BatchModule.doStart(BatchModule.java:104)
    at org.sonar.batch.bootstrap.Module.start(Module.java:83)
    at org.sonar.batch.bootstrap.BootstrapModule.doStart(BootstrapModule.java:121)
    at org.sonar.batch.bootstrap.Module.start(Module.java:83)
    at org.sonar.batch.Batch.execute(Batch.java:104)
    at org.sonar.runner.DeprecatedAntLauncher.execute(DeprecatedAntLauncher.java:83)
    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.sonar.runner.DeprecatedAntTaskExecutor.delegateExecution(DeprecatedAntTaskExecutor.java:110)
    at org.sonar.runner.DeprecatedAntTaskExecutor.execute(DeprecatedAntTaskExecutor.java:65)
    at org.sonar.ant.SonarTask.launchAnalysis(SonarTask.java:86)
    at org.sonar.ant.SonarTask.execute(SonarTask.java:75)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:392)
    at org.apache.tools.ant.Target.performTasks(Target.java:413)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.Main.runBuild(Main.java:811)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)Caused by: org.sonar.api.resources.DuplicatedSourceException: Duplicate source for resource: com.iwf.ImageSearchCommand
    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:419)
    at org.sonar.batch.DefaultSensorContext.saveSource(DefaultSensorContext.java:161)
    at org.sonar.plugins.java.JavaSourceImporter.importSource(JavaSourceImporter.java:83)
4

1 回答 1

0

听上去像:

根本原因是同名的源文件和测试文件。解决方案是从声纳分析中排除测试文件

于 2012-12-27T01:23:15.633 回答