spoon 的源码分析,对于一个大项目的源码,我们如何处理"The type xxx is already defined"?

How do we deal with "The type xxx is already defined" in spoon's source code analysis for a big project's source code?

我们在用spoon分析Hadoop这样的大项目的源码时,经常会出现这个问题"The type xxx is already defined",因为可能存在Java class个相同的class不同子项目中的名称和相同的包目录。

当我 运行 "java -cp xx spoon.Launcher -i ~/hadoop-0.23.3-src/ -p myspoon.CatchProcessor".

时出现以下错误
Exception in thread "main" spoon.compiler.ModelBuildingException: The type JobInProgress is already defined
    at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.reportProblem(JDTBasedSpoonCompiler.java:550)
    at spoon.support.compiler.jdt.TreeBuilderRequestor.acceptResult(TreeBuilderRequestor.java:37)
    at spoon.support.compiler.jdt.TreeBuilderCompiler.buildUnits(TreeBuilderCompiler.java:73)
    at spoon.support.compiler.jdt.JDTBatchCompiler.getUnits(JDTBatchCompiler.java:120)
    at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildUnits(JDTBasedSpoonCompiler.java:410)
    at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildUnitsAndModel(JDTBasedSpoonCompiler.java:372)
    at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildSources(JDTBasedSpoonCompiler.java:348)
    at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:119)
    at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:102)
    at spoon.Launcher.buildModel(Launcher.java:700)
    at spoon.Launcher.run(Launcher.java:651)
    at spoon.Launcher.run(Launcher.java:106)
    at spoon.Launcher.main(Launcher.java:99)

而且我发现在同一个子项目中有两个JobInProgress.java "hadoop-mapreduce-project"

./hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobInProgress.java
./hadoop-mapreduce-project/src/java/org/apache/hadoop/mapred/JobInProgress.java

那么如何解决这个问题????? 我已经发现似乎我们不能将两者之一移到 运行 勺子分析,因为它会导致 "missing files"

的另一个问题
Exception in thread "main" spoon.compiler.ModelBuildingException: The import org.apache.hadoop.conf cannot be resolved at xxx

对问题有什么意见吗?谢谢

像Hadoop这样的项目定义了几个独立编译的子模块:那么你不能把整个源代码看成一个大项目。

Spoon 不支持带有子模块的 maven 项目,所以你必须将每个子模块单独提交给 Spoon,但这样做时你必须尊重模块层次结构,更重要的是,你必须使用正确的类路径: 例如,如果模块A依赖于模块B,那么在分析A时不要忘记传递B.jar