Importing a module screws up my directory paths

Answered

So I've created a project that will have multiple modules. My directory structure is as follows:

 

ProjectRoot

    module1

        src

            main

                java

            test

                java

    module2

        src

            main

                java

            test

                java

 

I want to turn module 1 and module 2 directories into IntelliJ modules. However, when I try to import them as modules, it ignores the directory I select, and goes down to one level above the sources root.

 

To explain, in module1, if the "java" folder is a sources root, it'll make the "main" folder the module root, even though I'm selecting "module1" as the module root, two levels higher. I intend to add other folders to the module, resources, libs, etc, I don't want this.

 

I could just use the New Module option, but I'm loading this project from github that I created on another machine, I should be able to just rebuild the module settings that I'm after here.

 

How do I ensure that IntelliJ doesn't automatically change the module root on me? Thanks.

5 comments
Comment actions Permalink

If you already have your modules configured and saved in .iml files, they can be imported later on another machine.

If not, creating a new module would be best option, you can specify any module root and content root when the module is created.

You can later add .idea directory and .iml files to Git so that this project can be opened in IDEA on any machine. See https://intellij-support.jetbrains.com/hc/articles/206544839.

1
Comment actions Permalink

Same problem. 

No offense, but your second sentence seems to be false, Serge. Intellij seems to only suggest foo/src/main as a module. 

IntelliJ IDEA 2017.1.2
Build #IU-171.4249.39, built on April 25, 2017

0
Comment actions Permalink

What do you mean? In the New module dialog you specify the module content root, once the module is added you specify which directories will be Source.

0
Comment actions Permalink

Maybe I'm commenting on the wrong post. I'm trying to create a new module from existing sources. My existing sources are like Craig's. At this point in the wizard, I'm at a loss.

 

At this step, I would like it to suggest "module1" as the module to import as there are other files within module1 that I would like to treat as a module. 

For now, I'm creating a fake java file directly under src to get around this.

Thanks for your time.

0
Comment actions Permalink

Use New Module instead of importing.

1

Please sign in to leave a comment.