Eclipse file search finds the same file multiple times

后端 未结 11 1286
生来不讨喜
生来不讨喜 2020-12-23 20:22

In Eclipse I have two maven projects A and B, where A is a parent for B. The directory structure is the following:

A/pom.xml
A/B/pom.xml
A/B/...
相关标签:
11条回答
  • 2020-12-23 21:12

    As a new joiner, still couldn't comment but I'd really like to add something to the best answer. It works! It not only removed the duplicate files for me (one from child module and one from parent module), it also removed the class files from parent module).

    But it added the folder to my .gitignore which will cause problem for new files/directories added later. I just reverted the change to .gitignore and it still works in eclipse.

    Find this answer to disable auto change of .gitignore EGit and Eclipse modifies .gitignore file but it should not

    0 讨论(0)
  • 2020-12-23 21:17

    What I personally do to avoid this is marking each module in the parent project as derived (right-click on the folder > properties > Attributes: Derived).

    Then when you perform a file search, uncheck "Consider derived resources" (I don't think it is checked by default) and you won't get the A/B/<my_file>.

    The only inconvenience is that you must do this for each module, and each time a new module is added.

    0 讨论(0)
  • 2020-12-23 21:17

    In addition to "Hide folders of physically nested modules" mentioned above, I've found another simple solution, only by unchecking parent modules when importing Maven project:

    0 讨论(0)
  • 2020-12-23 21:24

    Checking Window -> Preferences -> Maven -> Hide folders of physically nested modules (experimental) worked for me in Mars.1 Release (4.5.1).

    After checking it I closed all projects within eclipse, deleted eclipse project files (.project, .classpath and .settings) and reimported my maven projects.

    0 讨论(0)
  • 2020-12-23 21:24

    You can solve this problem using a flat multi-module approach.

    Caveats may apply if you're using the maven-release-plugin with a version control system other than Subversion.

    0 讨论(0)
提交回复
热议问题