Renaming Maven projects' parent folder loses their Maven project status, and the folders marked as Source Roots etc. get unmarked

Answered

I uploaded a small minimal sample, Upload id: 2026_08_16_y3g1BJ1amPUoi743hmGp6j (file: ModulesToShowStatusLossOnRename.zip)

The folder ModulesToShowStatusLossOnRename contains a small subtree with 4 Java modules (Maven projects) across its
2 folders (Folder-A and Folder-B). There is no parent POM.

Folder-A contains 3 modules (Maven projects). When I right-click it in Project view and I rename it, the 3 Maven
projects become no longer Maven projects, f.ex. the Maven icon (the blue "m") at the left of the pom.xml gets
replaced by a "</>" icon, and now if I right-click a pom.xml I have the option "Add as a Maven project", which I am
then forced to use every time I rename the parent folder of those Maven Projects. Also, the subfolders that were
marked as Sources Root, Resources Root etc. lose that status as well.

Furthermore, interestingly, if after doing "Add as a Maven project" to make it become a Maven project again, I rename
the parent folder to what it was before, the modules stay Maven projects - it seems that they lose their status of
Maven projects only if the name to which their parent folder gets renamed is a new name, not the one that that folder
had before.

Also, when I rename the parent folder so the modules lose their status of Maven projects and the subfolders lose their
status of Sources Root, Resources Root etc., and then I immediately rename back that parent folder to what it was
before, the projects automatically regain their status of Maven projects and the subfolders their status of Sources
Root, Resources Root etc.

I must reiterate that I am renaming the parent *folder* that contains the modules under it (Folder-A, Folder-B). I am not
renaming the folder that constitutes the module (TestedModule1, TestedModule2 etc.).

Weird, I know, but I repeated the process several times and I must stand by this description. I also tried this with
Folder-B instead of Folder-A and it's the same.

 

0
1 comment
Thanks for the sample project. It reproduces the bug on the first try.

I reproduced it on IntelliJ IDEA 2026.2.1 (build IU-262.9437.185) on Windows 11 and filed IDEA-392831 (https://youtrack.jetbrains.com/issue/IDEA-392831). Follow that issue for updates.

The cause is in how the IDE stores the link to each POM. When you use Add as Maven Project, the path goes into .idea/misc.xml, relative to the project root:

<component name="MavenProjectsManager">
  <option name="originalFiles">
    <list>
      <option value="$PROJECT_DIR$/Folder-A/TestedModule1/pom.xml" />

The rename does not update those paths. They still name the old folder, so none of them resolve and the POMs stop being Maven projects. The Sources Root and Resources Root markings go with them, because Maven import is what applies those.

Your description was accurate in every detail, including the two parts that look strange. A rename back to the old name works because the stored path becomes valid again. A name the folder never had breaks it, because it leaves a path pointing at nothing.

You can avoid re-adding every POM by hand. I tested these steps on your sample:

1. Close the project.
2. Open .idea/misc.xml in a text editor.
3. In the originalFiles list, replace the old folder name with the new one on every affected line.
4. Open the project again.
5. Run Reload All Maven Projects from the Maven tool window.

Step 4 brings the POMs back as Maven projects. Step 5 restores the source and resource root markings, so do not skip it.

The same mechanism explains most cases of a Maven project not being recognized, which this article covers: How to troubleshoot if Maven Project is not recognized by IntelliJ IDEA (https://youtrack.jetbrains.com/articles/SUPPORT-A-4229).
0

Please sign in to leave a comment.