-
Notifications
You must be signed in to change notification settings - Fork 290
Setting Up Multiple Interdependent Projects in IntelliJ IDEA
Setting up multiple interdependent projects in IntelliJ IDEA, especially when they are part of the same repository or depend on each other, requires careful structuring to ensure that changes in one project are reflected in the others. Here’s a step-by-step guide on how to set up your Gradle projects in IntelliJ IDEA to handle dependencies and ensure compatibility with Java 17:
If you haven't already cloned the repositories, you can do so directly from IntelliJ IDEA:
- Open IntelliJ IDEA.
- Select File > New > Project from Version Control.
- Enter the repository URL (for example,
https://github.com/MegaMek/megamek.git
) and choose where to store the project locally. - Repeat for the other repositories (MegaMekLab and MekHQ).
-
For MegaMekLab:
- Navigate to the MegaMekLab project directory.
- Create a file named
settings_local.gradle
with the following content:
includeBuild '../megamek'
-
For MekHQ:
- Navigate to the MekHQ project directory.
- Create a file named
settings_local.gradle
with the following content:
includeBuild '../megamek' includeBuild '../megameklab'
Since MegaMek is the base project that others depend on, open it first:
- Open IntelliJ IDEA, if it’s not already open.
- Select File > Open and choose the MegaMek project directory.
Since MegaMekLab and MekHQ are dependent on MegaMek, you need to add them as modules:
-
Add MegaMekLab as a Module:
- With MegaMek open in IDEA, go to File > New > Module from Existing Sources.
- Navigate to the directory where you cloned MegaMekLab.
- Select its
build.gradle
file and follow the prompts to add it as a module. - IntelliJ IDEA will recognize the
settings_local.gradle
and include the MegaMek build.
-
Add MekHQ as a Module:
- Repeat the process for MekHQ:
- Go to File > New > Module from Existing Sources.
- Navigate to the directory where you cloned MekHQ.
- Select its
build.gradle
file and follow the prompts to add it as a module. - IntelliJ IDEA will recognize the
settings_local.gradle
and include both the MegaMek and MegaMekLab builds.
- Repeat the process for MekHQ:
Now, set up the dependencies between these modules:
- Go to File > Project Structure.
- Under Modules in the left sidebar, click on MegaMekLab, then go to the Dependencies tab.
- Click the + button, select Module Dependency, and choose MegaMek.
- Similarly, select MekHQ, go to the Dependencies tab, add MegaMek and MegaMekLab as dependencies.
To ensure everything compiles and runs correctly with Java 17:
-
Set Java 17:
- Go to File > Project Structure.
- Ensure the Project SDK is set to Java 17. If not, configure it to use Java 17.
- Ensure each module is also set to use Java 17.
-
Set Gradle JVM:
- Go to File > Settings (or IntelliJ IDEA > Preferences on macOS).
- Navigate to Build, Execution, Deployment > Build Tools > Gradle.
- Set Gradle JVM to Java 17.
If you make changes to project settings that should be shared with other team members, remember to commit these changes back to your repository:
- Use the VCS > Commit dialogue to commit your changes.
- Push the changes using VCS > Git > Push.
Run each application within IDEA to ensure that the dependencies are correctly recognized and there are no compilation issues:
- Run MegaMek.
- Run MegaMekLab.
- Run MekHQ.