Move .iml files to other directories?

已回答

Hi

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.


Regards
GarfieldKlon

2

Hello.

Unfortunately, this is not supported yet: http://youtrack.jetbrains.com/issue/IDEA-111848

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.

Regards,
Alexander.

0

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.

2

Thanks Jpayoung! Seems to work :)

I much prefer this file to live under the .idea folder, especially when contributing to a project owned by somebody else. It's much more common for .gitignore files to already have .idea listed. Adding .iml to somebody else's .gitignore is not ideal.

0

I don't understand Jetbrains... it's like they have 12 different teams going in different directions, removing functionality, adding it back, changing it without updating documents... a little nutts!

Anyway, they used to have this option to store them in .idea folder, now they have a more confusing option called "store generated project files externally" which seems to accomplish the same thing and I assume moves the iml files somewhere in the user directory.

0

Jpayoung's solution no longer seems to work for me.  After dragging the `.iml` file into the `.idea` folder, I then need to open `./idea/modules.xml` and update the path to the `.iml` file manually by adding `.idea/` in between `$PROJECT_DIR$/` and the `.iml` file name.

Agree with gunslingor gunslingorsadf that this situation is quite annoying.

2

请先登录再写评论。