Import projects with different groups but same name

Answered

Hi,

I try to import two gradle project one by one into same "workspace".

They have structure :

  • projectA
    • submodule
  • projectB
    • submodule

where submodule is the same name for projectA and projectB (they have different group name). It appears that Idea can't import second project, because its try to make ij project with name "submodule", which exists (created by previous import).


Main problem is that name of module is created considering only project name, not project group, which can cause namespace error like I encounter.

I workaround this by change name of ij project after import, then I was able to succesfully import second project.


Is there any way to do it correctly [import should create module name by considering  group name and project name]?

Or should I fill a bug ?

Regards,

Grzesiek
4
9 comments
Avatar
Permanently deleted user

I got the same issue too, the pycharm is not working properly since then 

0

@Karam Qusai could you provide more details? For Gradle-based projects IDE takes module name according to Gradle rules.

By default, Gradle uses the directory name as project name. You can change this by creating a settings.gradle file in the directory which specifies the project name.

0

Hi Andrey Dernov,

I currently have the same issue. unfortunately you are using the project name. But Gradle projects itself consists of different names - the group, the actual module name and last but not least the artifact name. 

IntelliJ Idea is only taking the module name into account (which is NOT the unique identifier). The unique identifier is typically the fully qualified path of the module. 

E.g. Having ":client:api" and ":platform:api" is totally fine for Gradle, as long as both modules (a) don't have the same artifact name and (b) don't have the same group. But typically, both are considered valid. 

But whenever I have a third module, which is using the above modules, the third module will only find one of them, not both, since for IntelliJ both only have the name "api" which isn't correct.

0

>unfortunately you are using the project name.

@Timo Gruen994 IntelliJ IDEA the same as Gradle uses full path to a module starting from the project root directory as the module name. For example if there is a gradle-parent project with projectA and projectB submodules with the name submodule the full name for these submodules will be gradle-parent.projectA.submodule and gradle-parent.projectB.submodule.

>IntelliJ Idea is only taking the module name into account (which is NOT the unique identifier). The unique identifier is typically the fully qualified path of the module. 

In which case do you mean? Can you describe the exact problem in more details? Thank you.

 

0

Hi Andrey Dernov,

thanks for reaching out to me so fast!

I got an example project here: https://github.com/Lacritz/multi-module-example

Unfortunately, the error only occurs when renaming modules and not always. And only if the last crumb of the module name is exactly the same. Can't reproduce it currently. (But it happened while renaming projects + renaming their corresponding includes in the settings.gradle.kts). Was able to fix it with deleting the sub-module and adding it manually.
In the example you can find a module `platform:api` and `platform:client:api`. Only if there is another module depending on the latter one, it might come to the issue, that the module can't find the `platform:api` OR `platform:client:api`. 

Adding my IntelliJ information here, in case those are important.

IntelliJ IDEA 2020.3.1 (Ultimate Edition)
Build #IU-203.6682.168, built on December 29, 2020
Licensed to Timo Grün
Subscription is active until February 11, 2021.
Runtime version: 11.0.9.1+11-b1145.63 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.16
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 16
Non-Bundled Plugins: com.github.setial, com.mighty16.json.kotlin.class, wu.seal.tool.jsontokotlin, org.jetbrains.kotlin, org.asciidoctor.intellij.asciidoc

0

The steps to reproduce would be very helpful. As well as the expected/actual result. And if the Gradle is able the project when issue occurs. As currently the issue is still not very clear to me. Thank you.

Please also note that you should rename modules using Gradle means, and not do it in the IDE UI.

0

I can't reproduce it currently. But it happened under the following circumstances the last time:

(1) Rename `platform:client:api` to `client:api` and `platform:client:impl` to `client:impl`.

(2) Repeat to rename it vice versa

(3) Sometimes `client:impl` / `platform:client:impl` won't be able to access the imports on one of the apis (`platform:client:api` or `platform:api`)

The expected behavior would be, that IntelliJ still is able to check whether the two APIs are part of the dependency tree of the module, or not. 
Note: Invalidating the cache wasn't able to fix the issue. I was only able to fix it deleting one of the APIs and add it manually again. 

 

Since the issue isn't easily reproducible and I'm not blocked - feel free to skip the issue and I will add a new comment, once I see the issue once again. (which is unlikely, since refactoring the whole project structure isn't a thing which happens all too often)

0

How do you do a rename?

0

Using the function `Rename Module` of IntelliJ plus renaming the module manually in the `include` part of the `settings.gradle.kts`

0

Please sign in to leave a comment.