IntelliJ Picking up the wrong module and wrong class

Answered

I have a project consisting of a number of Maven projects. Two of the modules have the exact same name and a class that has the same package and class name (Java). When I try to run a build the messages tell me there is a symbol not found issue. When I command click to follow the reference I noticed it was pulling the wrong module. I fixed this in the Module Settings and tried recompiling but I am still getting the same results.

 

Is there a way I can more explicitly describe which module to use? Preferably in a way that won't be reverted once I try to do a maven or gradle rebuild.

2
2 comments

>Is there a way I can more explicitly describe which module to use?

Build classpath is constructed from all the dependencies, which are specified for the module in Dependencies tab (the order of dependencies also matters). In case of a Maven project IDE configures it automatically, based on pom.xml file.

Can you build the project from Maven? How do you declare the dependency on this class (as jar, as module dependency)? There could be an issue if module with the same name is used as a dependency: https://youtrack.jetbrains.com/issue/IDEA-178903

0
Avatar
Permanently deleted user

I fixed this issue by changing the modules.xml file into the .idea folder.

0

Please sign in to leave a comment.