2022-04-17

Fixing broken module names in IntellijIdea

Quite often, when I rename a maven module, IntellijIdea gets confused and keeps showing the old module name in the project view.

  • Re-importing maven projects does not help.
  • Clearing the IntellijIdea caches and restarting does not help.
  • Even deleting the .idea directory does not help.

I discovered that this is happening because: 

  • IntellijIdea keeps information about a project outside of the .idea directory
  • IntellijIdea fails to delete that information when you invalidate caches and restart.

The solution I have found to this problem is:

  1. Exit IntellijIdea.
  2. Go to the application data directory of IntellijIdea (on my Windows machine, this currently is %USERPROFILE%\AppData\Local\JetBrains\IdeaIC2022.1)
  3. Delete the `external_build_system` subdirectory
  4. Start IntellijIdea.
  5. Re-import all maven projects.

Update:

Shortly after I discovered this, a new release of IntelliJ IDEA came out, (IdeaIC2021.3) and there appears to be no "external_build_system" subdirectory in its directory. Miraculously, it makes use of the "external_build_system" subdirectory of the IdeaIC2021.1 directory!

Also, with this new version, when I apply the above steps, IntellijIdea for some reason starts to believe that I have chosen to "ignore" all of my pom.xml files.  So, I have to open up maven settings, go to "Ignored Files", and uncheck every single one of my pom.xml files.