Intellij IDEA can't import two gradle projects containing submodules with the same name - intellij-idea

I have two gradle project:
projectA
submodule
projectB
submodule
Both submodules have the same name (but other group id). When I try to import both project to same workspace in IDEA, it imports one project correctly (root module + submodule) and only root module of second project. When I try to manually import missing submodule, it don't allow to it. because: "module "submodule" already exists in the project".
Is this a bug in IDEA ?
Is there any way to import this correctly?
I workaround this by change IDEA project name of "submodule" to "A-submodule", but I suppose that it must be a better way to do it.

Related

How to quickly import `package.json` as npm-module?

In IntelliJ I am used to create IntelliJ-Modules out of Maven pom.xml files. I just rightclick on the pom and choose + Add as Maven Project.
Is there something similar for npm modules? Maybe by rightclicking on the package.json file?
I do not want to use the cumbersome way of navigating to Project structure, Modules and clicking on +, import Module, and so on.

How to open pom.xml project using IDEA

I am trying to learn about annotation processing by looking at this sample.
I've cloned it to my local machine and used IDEA to open it.
However IDEA tells me:
Project SDK not set up.
After setting up Java SDK, the project is not opening correctly. So how can I open this project?
The project structure :
annotationprocessing10
|
|------factory
|-----annotation
|------pom.xml
|-----processor
|------pom.xml
|-----pom.xml
|-------factory-sample
I tried opening annotationprocessing10 (root) directly and also tried factory directly but neither worked. Here is a screenshot of the directory structure:
The given repo is not a maven module (no POM.xml in the base directory), the maven modules are the projects inside.
Make sure you import the modules inside the root directory in IDEA to identify it as a maven project.

How to import a project with modules and java packages in IntelliJ?

We have a java project with several modules. We use git for versioning and want the developers to be able to chose their own IDE. So we don't push .idea and .iml files with git. This means that developers in IntelliJ needs who clones from git needs to set up the project in IntelliJ as well. However we are having some issues with setting it up. In my own project it works fine and looks like:
Proejct Module (Is this a real module?)
⤷ Module A
⤷ src
⤷ main
⤷ java
⤷ Package 1
⤷ Package 2
⤷ test
⤷ Module B
Before we added packages to the project new developers could just pull from git and open Module P in IntelliJ, then go to project structure and import module from Module A and Module B. However if they try the same thing now IntelliJ tries to make the Modules main and test from Module A.
A workaround we temporarily use for this is to open Module A and B directly as separate IntelliJ projects. If we do this IntelliJ does not try to make modules out of main and test. However this is very inconveniant for us.
How can we fix this?
It's a good approach to make your source control system "agnostic" about the IDE and not check in .idea, *.iml and equivalent things from other IDE's.
However you really need to use a build control system like maven or gradle.
In my workplace we use maven for all our java projects. It's very simple to define a pom.xml at the root level which defines your modules, and many other things.
When you import a maven project into intellij, all the relevant IntelliJ modules are automatically created for you. In essence, you only need to import the pom.xml and you're good to go.
Otherwise it will be a nightmare to import and create modules every time you check out source from git. Maven isn't perfect but I highly recommend using either maven or gradle.
To define multi-modules from the root pom.xml, make a section like this:
<modules>
<module>module-A</module>
<module>module-B</module>
</modules>
And then the pom.xml in both module A and B should define a section referring to the root pom via the <parent> tag.

Opening multiple projects in Intellij Idea, having their own modules

I have two projects, having their own modules:
projectA
moduleA1
moduleA2
projectB
moduleB1
moduleB2
I want to edit both projects at the same time with Intellij Idea. They advice to import one project as a module of another. Ok, let projectA be a module of projectB. I'd like to see the structure:
projectA
moduleA1
moduleA2
projectB
moduleB1
moduleB2
But I get
projectA
moduleA1
moduleA2
moduleB1
moduleB2
What am I doing wrong? Is there any capability not to unwrap the current project structure?
Not going into the configurations of the classpath and other variables, just simply the file structure; I had the same problem at first when attempting to re-create your scenario. Though it is a simple "over-looked" setting of the modules.
The overall layout is:
Now when adding another module (in this case "ModuleA3", Intellij will set the default path to: $PROJECT_DIR$/Module3A
Because of this, Intellij is trying to create this module as a sub-module of the "Top-Level Project"; the solution is somewhat simple, change the path to:
$PROJECT_DIR$/ProjectA/Module3A
EDIT: I can now post images so I included my originals for this question; I find them easier to see what is going on.
-Thomas

maven m2eclipse multi module project

I have a multi module maven project and the directory structure is hierarchical. Some modules have dependencies on others. I have added the dependent modules to the dependency section of the project's POM. However, in order to resolve those dependencies, I need to import the parent project, and select Project Properties > Maven and select "Enabled Modules." Is this normal? Why wouldn't the project just resolve the dependent project in the workspace?
thanks,
Jeff
However, in order to resolve those dependencies, I need to import the parent project, and select Project Properties > Maven and select "Enabled Modules." Is this normal?
No. When you import your projects, unfold the Advanced part and make sure that Resolve Workspace projects is checked (that should be the default though).
You can also change this setting at the project level. Just right-click on a project, select Properties > Maven and verify that Resolve dependencies from Workspace projects is checked.
UPDATE: Answering a question asked in a comment by the OP. From https://docs.sonatype.org/display/M2ECLIPSE/Dependency+Management about Include modules:
When enabled, dependencies from all nested modules are added to the "Maven Dependencies" container and source folders from nested modules are added to the current project build path when running "Update Sources" action. This option is enabled when you import multiple Maven projects as single Eclipse project, e.g. when "Separate projects for modules" option is turned off in the project import wizards.