-
Notifications
You must be signed in to change notification settings - Fork 291
Complete Development Environment Setup using IntelliJ Idea
This goes over a complete development environment setup for MegaMek, MegaMekLab, and MekHQ. It starts assuming a completely fresh Windows computer, which was my starting state for the guide. This includes setting up a composite build for the three programs, so that the local code is used for all builds.
- Install Base Programs
- Install Notepad++
- Install a Zipper - 7-Zip
- Install Git
- Install JDK
- Install IntelliJ IDEA
- Install Discord
- Create Accounts and Account Setup
- Create GitHub Account and Setup Forks
- Create Discord Account and Join Our Discord Server
- Reboot Your Computer (Recommended)
- Setup Git
- Initialize Git Repositories
- Rename Git Repositories (Optional)
- Download Reference Copies (Recommended)
- Setup Composite Build
- MegaMekLab
- MekHQ
- Save the File Changes
- Setup IDEA
This goes over downloading and installing the base programs you will need to work on the suite.
- Download the latest version listed here. We recommend downloading the 64-bit installer.
- Run the installer to install Notepad++.
- Select your preferred zipper. We recommend using 7-Zip. Do not use the built-in Windows Zipper (see here for reasons why).
- Download the latest stable (non-Alpha/Beta/Dev) release listed here. I recommend downloading the 64-bit exe installer.
- Run the installer to install 7-Zip.
- Download the installer here for your operating system. You do NOT want a GUI client as the vast majority of people find them harder to use.
- Start running the installer, selecting options as desired (I left mine as the default) until you reach the default editor.
- Change the default editor to Notepad++, as per below.
- Continue through the installer. We use the recommended settings, and highly recommend the "Checkout Windows-style, commit Unix-style line endings", "Use MinTTY", and "Enable file system caching" option selections, all of which should be as per default.
This is best covered by this guide.
- Download the installer here. We recommend the Community version, .exe installer.
- Run the installer. The only part you'll need to make changes to is the installation options. We recommend (and use) the following settings.
- We went with restart later, which is step 3.
- Download the installer here for your operating system.
- Run the installer.
- Go to here.
- Select Sign Up (at the top right)
- Go through the sign up to create your account.
- Open the MegaMek, MegaMekLab, and MekHQ GitHub pages.
- Select Fork on the top right of each webpage to create the fork for that part of the suite. Don't click on the numbers, as that just opens up a list of all forks.
- Load the Discord App.
- Selected Register, which is currently located right under login.
- Fill everything in, thus creating the account.
- Join our Discord using this link.
With all the installs done thus far, I highly recommend rebooting your computer at this stage.
- Create a folder to hold your development setup.
- Right click on the white space below any files and select "Git Bash Here" from the popup list.
- Enter
git config --global user.name "John Doe"
into the Git terminal, replacing "John Doe" with your GitHub username. - Enter
git config --global user.email johndoe@example.com
into the Git terminal, replacing "johndoe@example.com" with your GitHub username. - Enter
git init
- Leave the terminal open, as you'll continue to need it
- Open GitHub
- Select your user image on the top right, and then select "Your repositories" from the dropdown.
- Open the three repositories you previously forked.
- In your Git terminal, type in
git clone https://github.com/JohnDoe/megamek
three times, replacing the link with the one from your forks one by one. - Enter
cd megamek
into the Git Terminal - Enter
git remote add upstream https://github.com/MegaMek/megamek
into the Git Terminal - Enter
git fetch --all
into the Git Terminal - Enter
cd ..
into the Git Terminal - Enter
cd megameklab
into the Git Terminal - Enter
git remote add upstream https://github.com/MegaMek/megameklab
into the Git Terminal - Enter
git fetch --all
into the Git Terminal - Enter
cd ..
into the Git Terminal - Enter
cd mekhq
into the Git Terminal - Enter
git remote add upstream https://github.com/MegaMek/mekhq
into the Git Terminal - Enter
git fetch --all
into the Git Terminal - Enter
git push
into the Git Terminal. If this executes fine, your git repositories should be properly setup. Otherwise, open a PowerShell or Command prompt window. If you opened a PowerShell window, entercmd
, thengit push
. It should bring up the ability to sign into GitHub using the website. If you do so, it will set up an OAuth token for the computer, which will allow you to push to GitHub going forward.
I personally rename the megamek, megameklab, and mekhq folders to mm, mml, and mhq. This makes it far faster to navigate between the repositories, but does require an additional step down the road. This leaves you with the following base file setup if you do step 7.
Go to here and download a stable and a recent dev release MekHQ bundle. These allow one to refer to the previous behaviour while coding, and are great for keeping ones test campaign files in. I put these into the same folder as the upper level of my git repositories.
This just provides a faster step by step guide to doing so. There's significantly more detail information about it here.
- Open the MegaMekLab folder
- Copy the settings.gradle file, and rename the copy to settings_local.gradle.
- Open settings_local.gradle in Notepad++.
- Delete all of the contents
- Paste the following text into the file, using the first version if you did the rename in Step 6 and otherwise using the second.
if (gradle.parent == null) {
includeBuild '../mm'
}
or
if (gradle.parent == null) {
includeBuild '../megamek'
}
- If you did not do the rename in Step 6, your composite build in MegaMekLab is setup. Otherwise, you'll need to continue as one more file needs to be added.
- Copy the settings_local.gradle file, and rename the copy to properties_local.gradle
- Open properties_local.gradle in Notepad++
- Delete all of the contents
- Paste the following text into the file.
mmDir = '../mm'
- Open the MekHQ folder
- Copy the settings.gradle file, and rename the copy to settings_local.gradle.
- Open settings_local.gradle in Notepad++.
- Delete all of the contents
- Paste the following text into the file, using the first version if you did the rename in Step 6 and otherwise using the second.
includeBuild '../mm'
includeBuild '../mml'
or
includeBuild '../megamek'
includeBuild '../megameklab'
- If you did not do the rename in Step 6, your composite build in MekHQ is setup. Otherwise, you'll need to continue as one more file needs to be added.
- Copy the settings_local.gradle file, and rename the copy to properties_local.gradle
- Open properties_local.gradle in Notepad++
- Delete all of the contents
- Paste the following text into the file.
mmDir = '../mm'
mmlDir = '../mml'
You need to save all of the file changes in Notepad++ before continuing to the next step.
- Open IDEA. We would recommend not doing this from one of the repository folders, but instead just using the standard launcher.
- Go through the initial load pages, which last until you hit a welcome page.
- Select Open
- Navigate to your local repositories. You should note that they have a black box (see below) on the folder. I believe that means that project files have been detected.
- Select the megamek / mm folder, then press "OK"
- Select Gradle project, as this will then automatically configure the repositories
-
Select "Trust the Project", then okay.
-
It will now load the project. You can close the daily hint and what's new, but otherwise just wait. In the backend it is doing a sync, base build, configuration, and creating an index. This will take a few minutes to do. I don't use the prebuild indexes, but that may speed it up a bit.
-
Once the sync is done and there is no longer anything mentioning indexing in the bottom right, download the Settings Repository plugin from https://plugins.jetbrains.com/plugin/7566-settings-repository/versions/stable. Choose the latest version created before your IDE download date. Go to Settings, select Plugins, click the Gear symbol and then click Install Plugin from Disk. Select the Plugin archive just downloaded and click ok. Click ok again and restart the IDE.
-
Go to File, Manage IDE Settings, and select Settings Repository.
- Enter
https://github.com/MegaMek/IDEASettings
into the Upstream URL field, then select overwrite local. This will pull down the standard MegaMek configuration settings.
-
Next, go to File and select Settings.
-
Go to Code Style, expand it, and then ensure all of the code styles use the Default IDE scheme.
- In the same settings dialog, select Inspections and change the profile from Project Default to MegaMek Default.
-
Next, go to File/Open in the top bar, and open the megameklab / mml folder. Trust the project, and open in this window.
-
Wait for the initial sync and indexing is done, but in the meanwhile watch the projects listed in the top left project view (you may have to collapse the megameklab / mml project). You should see both the megamek / mm and megameklab / mml repositories listed there pretty soon after your initial load (mine was there within a few seconds).
-
Once the sync is done and there is no longer anything mentioning indexing in the bottom right, repeat steps 11 to 13 for MegaMekLab.
-
Next, go to File/Open in the top bar, and open the mekhq / mhq folder. Trust the project, and open in this window.
-
Wait for the initial sync and indexing is done, but in the meanwhile watch the projects listed in the top left project view (you may have to collapse the mekhq / mhq project). You should see all three repositories listed there pretty soon after your initial load (mine was there within a few seconds).
-
Repeat steps 11 to 13 for MekHQ.
-
The repositories are now setup and will do a composite build.
-
This is just a verification, to ensure the build happens properly. We suggest going to the Gradle bar on the top of the right side bar, then go through the MekHQRoot/MekHQRoot/Tasks/application, and double clicking run. That will cause MegaMek, then MegaMekLab, and finally MekHQ to build. If MekHQ loads, then you've got your setup done.
Author: Windchild
Date: 08-Jan-2022