This guide describes how to set up midPoint in IntelliJ IDEA. IDEA impressed most of our development team members and makes out team much more productive.

This guide assumes you’ve cloned the repository and perhaps built it already. The guide only covers IDEA related steps, see also development guidelines and other guides and how-tos.

See the very end of this document for tl;dr/checklist version.

Install JAVA

JDK 11 (LTS) is supported for midPoint 4.0 and newer. You can download from Oracle JDK, but you better check the license. Or you can try more license-friendly releases like OpenJDK from AdoptOpenJDK or Zulu JDK from Azul.

JDK (sometimes called SDK) is necessary for building - JRE (just the runtime) is not enough.

Install IDEA

IDEA is provided in two editions. You can use free Community edition just fine, paid Ultimate Edition offers advanced support for web development and frameworks. Both editions allow building and running midPoint just fine.

  • Download IDEA from jetbrains.com.

  • Select the version for your operating system and edition.

  • Install IntelliJ IDEA on your computer.

Pictures in the guide are mix of both editions, but we will focus on the basics with the Community Edition.

Import of midPoint into IDEA

Importing midPoint into IDEA can be smooth if you have already built it before.

Note
It is possible to clone the project from GitHub directly in IDEA, but especially on Windows it is recommended to use command line to apply project specific Git configuration during the clone.

It is recommended to first build the project which avoids a few hiccups during the first import. We will show what happens if you don’t and the project can be built from IDEA too and reimported.

mp idea import

  1. Run the IDE and choose Open or import. If IDEA opens with existing project use File | Open from the main menu.

  2. Find the cloned midpoint directory, select it.

  3. Press OK to confirm.

Wait until the IDE settles and the progress bar at the bottom stops working.

Possible import problems before the first build

mp idea maven import

  1. If you haven’t built the project before (or deleted ~/.m2/repository/com/evolveum) IDEA can’t fully import the project, because Maven POMs reference midPoint plugins that are not built yet.

  2. On Windows, it is recommended to exclude IDEA’s working directory and project repository from Windows Defender scanning - IDEA suggests that and offers an automatic fix.

  3. Open the Maven panel on the right edge of the window (hidden behind contextual menu in the picture). Normally the list of Maven projects is flat, if you prefer it to follow the directory structure, click on the Maven Options menu.

  4. Check Group Modules to change the visualization of Maven projects structure.

IDEA JDK setup

Before we continue we will check that we’re using the right JDK in IDEA. In the menu, choose File | Project Structure…​ to open the Project Structure window.

mp idea project jdk

  1. Choose Project section in the Project structure window.

  2. Check that Project SDK shows JDK 11.

  3. If not, click Edit and set JDK as described on this help page.

  4. Alternatively you can access JDK setting via SDKs section on the left.

  5. Check the Project language level - normally it would be fine to use the level for JDK 11, but as of June 2020 we still secretly (but not officially anymore!) support JDK 8.

Setting Maven build

We may run the Maven build from IDEA, even the first before the project is synced properly.

mp idea maven profile and build

  1. We often want to Toggle 'Skip Tests' Mode - icon has to be highlighted - to avoid very long full build.

  2. It is also not necessary to build full distribution with IDEA, so you can uncheck dist in Profiles (it’s a bit laggy, be patient or try again).

  3. Finally, run the install phase from under the Lifecycle under the root project. It’s easy to locate the project with modules grouped, in the plain list it’s indicated with (root) after the name.

Without the tests and distribution the build can run for around 4-12 minutes.

Note
Phase package is not enough, we need to get midPoint plugins into the local repository under ~/.m2/repository.

After this we can reimport the Maven project:

mp idea maven reimport

  1. Click reimport icon in the Maven panel.

  2. This time everything should be synchronized properly.

  3. Project window will show the project structure with recognized modules marked accordingly (blue squares). When the change is detected in the POM files IDEA prompts us to reimport the project.

  4. Alternatively, we can choose one of the Auto-reload Modes.

Setting generated sources

During the Maven build of import/schema module, Java sources are from schema files. Unfortunately, the generated directory is not automatically recognized. This manifests as unrecognized classes from com.evolveum.midpoint.xml…​ packages. To add it manually, follow the steps in the picture:

mp idea marking generated sources

  1. To be sure, open a source file that uses the generated class, e.g. Action interface from model-impl module. Notice the unrecognized class.

  2. Locate infra/schema/target/generated/cxf directory, and right-click on it.

  3. Open Mark Directory as submenu.

  4. Click on Generated Sources Root.

After a while (click to editor may be needed) the missing files are recognized and the errors disappear.

Running midPoint in IDEA

TODO

Running the tests in IDEA

TODO

TODO

mp idea copyright profile mp idea unignore maven projects mp idea running test dummy connector classpath mp idea duplicate dependencies mp idea find library usage

Other IDEA customizations

  • To change the font size in the editor (it may be too small on some screens), see File | Settings | Editor | Font.

Short version (checklist)

Essential setup tasks:

  • Use JDK 11.

  • Run mvn clean install -DskipTests -P -dist at least once.

  • Import the project into IDEA as Maven project, set your JDK to 11.

  • Set Maven profiles, e.g. disable dist.

  • Mark infra/schema/target/generated/cxf directory as generated sources.

  • Add run configuration for MidPointSpringApplication with Provided dependencies included on the classpath and try to run it (shorten the command line if necessary, e.g. using JAR manifest).

  • Disable Maven modules Dummy Connector and Dummy Connector Fake under midPoint Icf Connectors but keep them as IDEA modules (to avoid incomplete refactorings). Try to run test like TestReconTask to check the setup.

Now you can perform other setup tasks like copyright headers, database settings, etc.