Why is the *.iml file stored in project root?

Answered

Hello everybody,

the title says about all i want to know.
Isnt the *.iml file supposed to be located in the .idea folder? Why is it (by default) saved in the projects root folder?

I know i can save it wherever i want, but its just so annoying to not know why the jetbrains developers decided to do it like this.

Hopefully some of you know the answer, as i was not able to find any information about this.

Best Regards,
Philipp

EDIT: maybe good to mention that i mostly use IntelliJ to create WebApplications (PHP, HTML, CSS, JS...)

8
10 comments
Avatar
Permanently deleted user

Hi Philipp,

I see at least two reasons for that:

  1. IJ used to use *.ipr file for keeping project info, i.e. it was not possible to keep *.iml at .idea dir as there was no such directory;
  2. It's easier to import a module from another project when module config file is kept at the module directory;

Denis

-1
Avatar
Permanently deleted user

Hi Denis,

thanks for your answer!

So the iml file should be in the .idea directory? Its just not possible because the system has changed?
I really like jetbrains products, but things like this are extremely annoying for me. Any chance to see this "fixed" in the future?

Best regards,
Philipp

PS: i cant agree with your second point, you just made this one up :p

0
Avatar
Permanently deleted user

I'm afraid I don't understand what kind of fix do you expect - it's possible to customize module configu file location on new module construction. It just defaults to module content root dir. Do you propose to change default locationt to .idea instead?

Denis

-1
Avatar
Permanently deleted user

As far as i understand this file, it should be located in the .idea directory.

Dont get me wrong, i know its not a bug or something, but its a strange default behaviour as it should be located with all the other project files (in the .idea directory).

2
Avatar
Permanently deleted user

There is a lot of other files which are located outside .idea :)

Basically, .idea holds project-level configs, there is also an app-level dir (defined at idea.config.path property at $IDEA_HOME/bin/idea.properties). Module-level changes are stored at *.iml which is located at module content root by default.

Denis

-1
Avatar
Permanently deleted user

i'm relatively new to IDEA.  i've somehow accumulated a bunch of *.iml files in my project root, and i'd prefer to have them somplace else.  my question is, how can i move the *.iml files without messing up my projects?

0

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.

1
Avatar
Permanently deleted user

@Yaroslav, thanks for your answer.

0

As per this answer on a similar topic: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206854115/comments/360000834879

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.

Seems to work.

0

Absolutely annoying. Yaroslav Bedrov's instructions helped a little although after move module doesn't look exactly correct. But things seem to mostly work on a pure ruby project.

It is correct that default location for the `.iml` file is in `.idea`. Why pollute project with IDE files when there is already a whole directory? At least make it easy to change the location.

1

Please sign in to leave a comment.