Skip to content

Setting Up Multiple Interdependent Projects in IntelliJ IDEA

Dave N edited this page May 11, 2024 · 3 revisions

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 projects in IntelliJ IDEA to handle dependencies:

  1. Clone the Repositories

    • If you haven't already cloned the repositories, you can do so directly from IntelliJ IDEA:
      1. Open IntelliJ IDEA.
      2. Select File > New > Project from Version Control.
      3. Enter the repository URL (for example, https://github.com/MegaMek/megamek.git) and choose where to store the project locally.
      4. Repeat for the other repositories (MegaMekLab and MekHQ).
  2. Open MegaMek as a Main Project

    • Since MegaMek is the base project that others depend on, open it first:
      1. Open IntelliJ IDEA, if it’s not already open.
      2. Select File > Open and choose the MegaMek project directory.
  3. Attach MegaMekLab and MekHQ as Modules

    • Since MegaMekLab and MekHQ are dependent on MegaMek, you can add them as modules to your MegaMek project:
      1. With MegaMek open in IDEA, go to File > New > Module from Existing Sources.
      2. Navigate to the directory where you cloned MegaMekLab, select its build file (pom.xml if Maven, build.gradle if Gradle), and follow the prompts to add it as a module.
      3. Repeat the process for MekHQ.
  4. Set Up Module Dependencies

    • Now, set up the dependencies between these modules:
      1. Go to File > Project Structure.
      2. Under Modules in the left sidebar, click on MegaMekLab, then go to the Dependencies tab.
      3. Click the + button, select Module Dependency, and choose MegaMek.
      4. Similarly, select MekHQ, go to the Dependencies tab, add MegaMek and MegaMekLab as dependencies.
  5. Configure the Build and Run Settings

    • To make sure everything compiles and runs correctly:
      1. Still in the Project Structure window, adjust the Build, Execution, Deployment settings as necessary to specify how each module should be built and what the dependencies are at runtime.
      2. Ensure that the SDK settings are correct and consistent across all modules.
  6. Commit and Push Changes

    • 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.
  7. Verify Everything Works

    • Run each application within IDEA to ensure that the dependencies are correctly recognized and there are no compilation issues.
Clone this wiki locally