Move .iml files to other directories?



I'm running into problems with my project structure. My .iml files are all located in the root directory. I have problems running junit Tests which reads files, then it looks in the root dir instead of the module dir.
$MODULE_DIR$ is set, but is referencing to the root because there is the .iml file.

So, how can I move them to the corresponding modules? Does just moving breaks something? Or is there an option in the project settings? I can't see one.


Comment actions Permalink


Unfortunately, this is not supported yet:

To do it manualy, please backup (commit) your project first.

Then you can try the following:
. (You may close the project to avoid interaction with IDE.)
. Move .iml to proper location.
. Revise and correct all paths in the .iml. E.g. instead of [content url="file://$MODULE_DIR$/module-name] set [content url="file://$MODULE_DIR$], and so on.
. Correct the paths in .idea/modules.xml for that module.

Various references directly into module content (not via module name), if you have any, should be corrected additionally.


Comment actions Permalink

Hi all,

Replies to this thread may no longer be relevant, but this is supported in the latest verisons of IntelliJ.

Dragging a file *.iml to a new folder in the from the Project Tool Window (⌘+1 / Alt-1) within IntelliJ will prompt a Move File Dialog for the .iml file.
Selecting the checkbox Search for references will find and update all references to the .iml file throughout the project.


Please sign in to leave a comment.