Today I met a strange issue when I was opening a Gradle project with multiple subprojects in IntelliJ IDEA.
First, after I clone the code from Github, as the “build.gradle” file shows, I run the following command to create IDEA project files:
1 | gradle cleanIdea |
They work properly. And the IDEA project files(both the root project and the subprojects) are created successfully.
But the problem is, when I open this project in IDEA, IDEA cannot recognize the project structure, which means no source code navigation, no libraries downloaded.
I cannot find anything wrong.
After a while, I read this and this.
Then I realize the problem might be caused by “one of the sub-project has the same name as the root project directory“. So I update the “build.gradle” file:
1 | { |
After that, IDEA can open the whole project properly.
The lesson learn here is, never use one name for two different things. And I don’t know why they are named so. I also think IDEA should have a better warning or error message for such problem, instead of showing nothing.