Advise for creating IntelliJ projects when dealing with multiple languages
Does IntelliJ support opening up a top level directory that has multiple source code repos under it? Is there anything special I can or should do to make IntelliJ know that I'm doing that?
(Q) If I create an IntelliJProject and then include that project in another IntelliJ project, does that cause problems?
For a full description, read below on what I'm trying to do.
I am a full stack developer and support several GIT repos with different apps and languages. I've experimented with IntelliJ in a few ways and run into performance problems due to "re-indexing" and figure I should ask the pros how to work with multiple applications in IntelliJ.
For the sake of discussion I have
JavaApp1 - ParentPom, Lib1, Lib2, Lib3
JavaApp2 - ParentPom, Lib1, Lib4
ReactApp1 - Pkg1, Pkg2
Pkg1 - Pkg3
Pkg2
Pkg3
Each of the above are GIT REPOs and the uses of the artifacts in the other GIT Repos.
I currently have a directory structure as follows:
wk/JavaApp1
wk/JavaApp2
wk/ParentPom
wk/Pkg1
wk/Pkg2
wk/Pkg3
wk/ReactApp1
If I open a given application directly, for example, wk/JavaApp1, when I create the IntelliJProject I tell it to import the POM and then manually add the other projects. So I have this:
I currently have a directory:
wk/JavaApp1/.idea - IntelliJProject has ParentPom, Lib1, Lib2 added
wk/JavaApp2
wk/ParentPom
wk/Pkg1
wk/Pkg2
wk/Pkg3
wk/ReactApp1
I then work on ReactApp1 and end up with
wk/JavaApp1/.idea - IntelliJProject has ParentPom, Lib1, Lib2 added
wk/JavaApp2
wk/ParentPom
wk/Pkg1
wk/Pkg2
wk/Pkg3
wk/ReactApp1/.idea - IntelliJProject for NodeJS/NPM
I continued doing this and have .idea directories for each app I'm working on.
Then I got the bright idea to create an IntellIJProject at the top level directory so I can easily search my entire code base.
wk/.idea - IntelliJProject that has sub-directory of different GIT repos
wk/JavaApp1/.idea - IntelliJProject has ParentPom, Lib1, Lib2 added
wk/JavaApp2/.idea - IntelliJProject has ParentPom, Lib1, Lib4 added
wk/ParentPom
wk/Pkg1
wk/Pkg2
wk/Pkg3
wk/ReactApp1/.idea - IntelliJProject for NodeJS/NPM
One issue (in the past, that seems to be fixed now), is IntelliJ would consider the node_modules directory as my code and would index it, and this would happen for multiple directories so IntelliJ would be useless during these indexing. The most recent versions of IntellIJ seem to have made that better.
So my question is this.
- If I've created an IntelliJ project at wk/.idea, and create other projects under that project (e.g., wk/JavaApp1/.idea) does that cause problems for IntelliJ?
- What is the best way to use IntelliJ to support multiple apps? Creating an IntelliJProject at the top level directory, or creating IntelliJProject's for each App?
Please sign in to leave a comment.
>If I've created an IntelliJ project at wk/.idea, and create other projects under that project (e.g., wk/JavaApp1/.idea) does that cause problems for IntelliJ?
There should be no issues with this. Just know that if you open the wk/.idea directory- IDE will include all other projects (modules) into project. And for this project then make sure the wk/JavaApp1/.idea directory is excluded from project - as you do not need to work with IDE project configuration files directly.
>What is the best way to use IntelliJ to support multiple apps? Creating an IntelliJProject at the top level directory, or creating IntelliJProject's for each App?
With IDE and it's funtionality any approach will work. Whichever is best suited for you. I think I would chose the base IDE directory to be the common Maven parent module: wk/ParentPom - then, if it is an aggregator Maven project, once I open it, other child Maven projects will be included automatically be the IDE. But I'm not sure about your actual Maven structure.
Thanks for the suggestion, and good to know that IntelliJ supports that (albeit unusual) way of creating a project.
A related question is:
(Q) If IntelliJ doesn't treat my Java directory as a MAVEN project, what is the way to make that happen? To tell IntelliJ to treat the directory as a maven project.
I think it's simply using the Maven Tool window and adding the directory, is that the right way to do this?
And similarly for a Javascript project, I'm not sure how plugins let's say for React JSX formatting "know" where the project top is, are they smart enough to look for the node_modules directory?
>(Q) If IntelliJ doesn't treat my Java directory as a MAVEN project, what is the way to make that happen? To tell IntelliJ to treat the directory as a maven project.
>I think it's simply using the Maven Tool window and adding the directory, is that the right way to do this?
Yes, you can import project via the pom.xml context menu or from Maven tool window.
>And similarly for a Javascript project, I'm not sure how plugins let's say for React JSX formatting "know" where the project top is, are they smart enough to look for the node_modules directory?
There is a related issue: https://youtrack.jetbrains.com/issue/WEB-31576 / https://youtrack.jetbrains.com/issue/WEB-23832 If import does not work - try to use File | Open action to open the root of React Native project and then link Maven modules the project.
One problem/feature that was really confusing until I understood what was happening is the Git History viewer.
It shows history for ALL of the git repos under the project which (at first I didn't realize). This can be very confusing if you are expecting to see the git history for the CURRENT repo that is being used.
Later I realized how beneficial this was when I was working on a git branch (call it feature/cool-stuff) and I had made changes on multiple repos with this same branch name.
The Git Viewer allows you to select just the branch which lets you see all the changes across multiple repos for any repos that have that branch name. I found this very cool. I never thought I would like to learn more about GIT viewing but I would.