Open QifanWang opened 2 years ago
This is indeed a problem because Spoon tries to build the model from all files at once. Spoon has no concept of multi-modules in its hierarchy, so having two classes with the same FQN will cause issues.
As an example, both https://github.com/apache/dubbo/blob/a66f5126745858f393c67c15d9a84f9e60405aba/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java and https://github.com/apache/dubbo/blob/a66f5126745858f393c67c15d9a84f9e60405aba/dubbo-demo/dubbo-demo-api/dubbo-demo-api-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java are in the same package and have the same simple name. Therefore, whenever asking for org.apache.dubbo.demo.consumer.Application
it is unclear which class is actually meant.
For this to work, you would currently need mutliple Launchers. Or probably it's enough to exclude the demo modules in your case?
Note there is also https://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/compiler/Environment.html#setIgnoreDuplicateDeclarations(boolean). This might make the error go away, but it will probably also break other things.
Hello,
I do not understand as the documentation states:
The Spoon MavenLauncher (JavaDoc) is used to create the AST model of a Maven project. It automatically infers the list of source folders and the dependencies from the pom.xml file. This launcher handles multi-module Maven projects.
(https://spoon.gforge.inria.fr/launcher.html)
Sincerely,
I may be mistaken, the documentation talks about Maven modules, not Jigsaw modules?
This bug seems related to #4751.
I do not understand as the documentation states:
The Spoon MavenLauncher (JavaDoc) is used to create the AST model of a Maven project. It automatically infers the list of source folders and the dependencies from the pom.xml file. This launcher handles multi-module Maven projects.
Yes, the issue here is the vague usage of "handles multi-module Maven projects". What that (currently) actually means it can find all the modules, it can find the dependencies of all the modules, but all the modules are on the source classpath for JDT, so JDT will try to compile all at once. I assume this can't be simply fixed in a non-breaking way in the current MavenLauncher,
I may be mistaken, the documentation talks about Maven modules, not Jigsaw modules?
This bug seems related to #4751.
Yes, the documentation of the MavenLauncher talks about Maven modules. The given project also doesn't seem to be based on Jigsaw modules, so that shouldn't be an issue here.
Describe the bug
I try to analyze Dubbo source code, but Spoon throws a ModelBuildingException. Shall I use Spoon to analyze such multi-pom.xml projects? Or I need to set some properties of maven laucher?
Source code you are trying to analyze/transform
Source code for your Spoon processing
Actual output
Expected output
Spoon Version
10.1.1
JVM Version
11
What operating system are you using?
Ubuntu 20.04.3 LTS