Support of maven submodules in Intellij 10

Dear all,

it looks like that there is only limited support for submodules in Intellij 10. We are experiencing the problem that .iml files for submodules are deleted by Intellij on restart. That makes it impossible to store settings along with submodules. The structure of our project is like:

main
- core
- web

We have 3 poms and 3 iml. But the core and web ones are deleted on restart.
Is that intentional? Is there are workaround? Or should that not be the case and we are doing something wrong?

Thanks
Rene

4 comments
Comment actions Permalink

This is indeed unexpected behavior. We have a maven project with that has a parent module with 8 child modules (i.e. sub modules). 3 of those children have 2 -5 sub-modules themselves (i.e. grandchildren). And one of those grandchildren has 4 sub-modules (i.e. great grandchildren). IDEA handles this seamlessly, creating (and retaining) the correct IDEA modules and .iml files.  They are not deleted on restart.

My guess would be that there is a configuration issue in your POMs. When configured to do such, IDEA will reimport your maven project (that is re-sync its modules with those in the POMs) on a restart. It sounds like when doing this, IDEA is not seeing those sub-modules as still existing, and therefore deleting the IDEA modules (and thier .iml files).

Verify that the 'main' module's POM has a <project><modules><module> entry for each sub-module that references the sub-module's directory (not the artifact name or id). Then make sure each sub-module has a <project><parent> entry referencing the main module. Also make sure your versions are in proper alignment.

As a verification that all is as you expect, drop to the command line and run the maven dependency:tree goal:
     mvn dependency:tree
Run it in the POM for the 'main' module. Make sure all your sub-modules are shown in the "Reactor build order" section and in the dependency tree.

Once everything is configured properly, do a force reimport all in the IDEA maven tool window.

0
Comment actions Permalink

Thanks for your help. Unfortunately that doesnt work. Also our project was setup according to your suggestions. Is there a way to switch off all kind of automatic detection related with maven modules?
I am experiencing now similar problems I had with Eclipse before switching to Intellij: I am always looking for a way to switch off features :)

0
Comment actions Permalink

You can turn off auto importing of a maven project in the project settings In the Settings dialog (Ctrl+Alt+S or File | Settings menu), in the top "Project Settings" section, expand the "maven" node and select the "importing" node. Uncheck the "Import Maven projects automatically" option.

I would however recommend trying to get to the root of your issue. Whether done automatically or manually, you will need to reimport your POMs any time you make a change to them (like adding a dependency) so that IDEA can synchronize its project settings to the change in the POM.

Does the .iml file disappear when you run the "Force Reimport All Maven Project" manually?  (The "Force Reimport All Maven Project" action is in the "Maven Projects" tool window. It is the left most icon with the two arrows that looks like a refresh icon). If so, then there is a configuration issue somewhere. Either in Maven or IDEA. You may want to try just recreating a new IDEA project from scratch. Although you should not have to do such, it might just help to start fresh.

If desired, I can provide a simple project that mimics your project. I do not believe is is possible to attach a zip file to these comments. But I can e-mail it to you if desired. That would allow you to verify if it is a problem with your project's configuration or not.

0
Comment actions Permalink

Hi Mark,

thanks for the hints. I thought about the whole problem again and with your hints I came to the conclusion that it must still be related to our pom in some way. Because if I understand it correctly Intellij builds some IML information based on poms. I found that one of our developers changed maven-war-plugin to use a different warSourceDirectory. This warSourceDirectory is used by Intellij to configure Web Facet including deployment descriptor and Web Resource Directory information. This configuration was overwritten by us manually. On restart or on running "Force reimport.." Intellij deleted the IML and configured it from scratch. I changed warSourceDirectory back to default value and did some manual configuration of the IML on top of it. Now Intellij is not deleting the IML anymore and also keeps the manual configuration.
I still do not understand why Intellij deletes the whole IML and builds it from scratch instead of just overwriting the manual configuration related to the Web Facet but at least the problem is fixed now. We are about to setup a new project in the next week. It may also help us to understand the problems with pom - IML interaction better.

Cheers
Rene

0

Please sign in to leave a comment.