Alex
Alex

Reputation: 18526

IntelliJ Project Structure full of "... and modules" and duplicates

I have to the following folder structure:

main
- server
-- server-module-1
--- a
--- b
--- c
-- server-module-2
--- d
--- e
--- f
- client
-- modules
--- client-module-1
--- client-module-2
--- client-module-3
- war-module

Maven Structure is similar - main pom.xml:

<modules>
    <module>server</module>
    <module>client</module>
    <module>war-module</module>
</modules>

The problem begins if I move one module to a separate profile since I don't need the war-module always (on Jenkins).

<modules>
    <module>server</module>
    <module>client</module>
</modules>

<profiles>
    <profile>
        <id>createModule</id>
        <modules>
            <module>war-module</module>
        </modules>
    </profile>
</profiles>

After this change, my IntelliJ my project structure looks like this:

main and modules
- client and modules
-- client-modules and modules
--- client-module-1
--- client-module-2
--- client-module-3
--- modules
---- client-module-1
---- client-module-2
---- client-module-3
-- client
--- modules
---- client-module-1
---- client-module-2
---- client-module-3
- server and modules
-- server-module-1 and modules
--- a
--- b
--- c
-- server-module-2 and modules
--- d
--- e
--- f
-- server
--- server-module-1
---- a
---- b
---- c
--- server-module-2
---- d
---- e
---- f
- main
-- client
--- modules
--- client-module-1
--- client-module-2
--- client-module-3
-- server
--- server-module-1
---- a
---- b
---- c
--- server-module-2
---- d
---- e
---- f
-- war-module

If I manually remove the "war-module" via Maven - "remove project", everything goes back to normal. However, since many people use this project we do not want this to happen to everyone all the time. IntelliJ seems to decide at random if it detects the war-module as a Maven module or not.

Any idea how I can stop IntelliJ from creating this "and modules" structure? I produces a number of weird side effects like opening folders if I expand it in another branch and is very uncomfortable to use.

Upvotes: 4

Views: 4068

Answers (1)

Alex
Alex

Reputation: 18526

The solutions seems to be disabling this setting when creating/importing the project in IntelliJ:

 Create module groups for multi-module projects

Disabling this setting later will not help.

If you do not want to reimport, you can manually fix the structure:

  1. Right-click on your topmost module (e.g. "main" - not "main and modules")
  2. Select "Move Module to Group" - "Outside any Group"
  3. The project should now be shown as before

Upvotes: 6

Related Questions