Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 28 Current »

This guide is a simple way how to start cooperate on project using IntelliJ IDEA (IDEA) environment.

Unless you really plan to modify the midPoint source code you probably do not need IntelliJ IDEA or any other heavyweight development environment. MidPoint can be easily built from the command line without an IDE. Please see the Installing MidPoint page for the details.

Introduction

JetBrains for providing IntelliJ IDEA - an IDE that impressed most of our development team members. IDEA makes out team much more productive.

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 https://adoptopenjdk.net/ or Zulu JDK from Azul.

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. But both editions allow building and running midPoint just fine.

  1. Download IDEA from jetbrains.com: http://www.jetbrains.com/idea/download/index.html
  2. Select the version for your operating system and edition.
  3. Install IntelliJ IDEA on your computer.

First run of IDEA

Outdated! There is a very good description of IDEA setup with screenshots contributed by Deepak Natarjan: idea-midpoint-init.pdf (attachment)

  1. You will be asked to import settings from previous version of  IDEA. If this is first time you're using IDEA, select „I do not have a previous version of IntelliJ IDEA or I do not want to import my settings" and continue.
  2. On next screen you will be asked for license data. Enter them and continue.
  3. Agree with license politics of IDEA
  4. On a couple of next screens you will be asked to select some IDEA plugins. The choice is yours, but some of the plugins are essential for working on midpoint. On first screen, select the Git VCS Integration plugin.
  5. Select these Web/JavaEE Technology plugins: 
  • Bean Validation
  • Database
  • FreeMarker
  • Hibernate
  • JSF
  • Java EE
  • Java Server Pages
  • Persistance Frameworks
  • SQL
  • Spring Data
  • Spring
  • Spring OSGi
  • Spring Security
  • pring Web Services
  • Spring-AOP and @AspectJ
  • Velocity
  • Web Services

     6. Select Application Server Plugin: Tomcat
     7. Select HTML/Javascript Development Plugins:

  • CSS
  • HTML Tools
  • Inspection-JS
  • JavaScript Debugger
  • JavaScript Intention Power Pack
  • W3C Validators

     8. Select Other plugins:

  • Ant
  • AspectJ
  • Copyright
  • Eclipse
  • Groovy
  • Inspection Gadgets
  • JUnit
  • Maven
  • Maven Integration Extension
  • TestNG-J
  • XpathView + XSLT

     9. Click Finish

Importing MidPoint project into IDEA

  1. Click File -> New Project
  2. Select 'Create project from scratch' -> Next
  3. Fill fields Project name and select Project files location -> Next -> Finish
  4. When new project is created, click VCS in top menu -> Checkout from Version control -> Git
  5. Click the '+' icon, fill in https://github.com/Evolveum/midpoint.git -> click OK
  6. Click on the midpoint repository -> Click Checkout.
  7. Select root folder of your project -> Click OK on several next screens, this will take a while
  8. Click on VCS again, select Enable Subversion Checkout Control -> OK
  9. In bottom menu, click on Event Log -> Click on the Settings Icon in left menu
  10. In AspectJ Group, Select 'No popup' option -> OK
  11. Now you'll need to install Maven 3 from http://maven.apache.org/download.html.
  12. On top menu, click Run -> Edit Configurations
  13. Click on '+' icon and select Maven
  14. In Parameters Section, choose your working directory, put 'clean install' in command line and 'default' in Profiles. Name your configuration as well.
  15. Click on General options. Unselect 'Use project settings' and in 'snapshot update policy' add value 'Do Not Update'.
  16. You may also need to set Maven home directory either to your M2_HOME classpath variable or override it to maven installation folder.
  17. In Runner option panel, unselect 'Use project settings' and mark 'Skip tests' value. Click OK.
  18. In main screen, select your previously edited configuration and click on green arrow icon. This will run the build of MidPoint. It may take up to several dozens of minutes depending on your hardware and internet connection speed.
  19. Download and install Tomcat 7 from http://tomcat.apache.org/index.html
  20. To run midpoint from IDEA, you will need to create user configuration. Click Run -> Edit Configurations.
  21. Click on '+' button in upper left corner of the screen, choose Tomcat -> Local.
  22. Name your configuration, then click on 'Configure' button located left to Application Server option.
  23. Edit Tomcat home and Tomcat base directory. -> OK
  24. Check  the 'Start browser' option and type 'http://localhost:8080/midpoint/login' in startup page. -> OK.
  25. Now run your new Tomcat configuration the same way like maven build before. Midpoint now should open in your default web browser.

Add Generated Sources

MidPoint build generates some source code during build. These are especially classes generated from XSD schemas. You need to add the folders that contain generated classes as source folders so IDEA can see them.

  1. From the command-line, run the build once: mvn[w] clean package
  2. Go to the infra/schema project and open module settings (right click and select Open Module settings or press F4)
  3. In the "Sources" tab click on "target" and uncheck the "Excluded" mark (in the "Mark as" bar)
  4. Expand "target/generated" and mark "target/generated/cfx" as "Sources"
  5. Mark all other sub-directories of "target" as "Excluded" (classes, cxf-codegen-plugin-markers, maven-archiver, ...)
  6. Repeat steps 1~4 for the model-client project.
  7. Click OK

Other Tips

  • Remove Spring Facets from the Project Structure (File -> Project Structure -> Facets). These do not work well with maven-based spring configuration. If the faces are present you may get false errors about duplication of some spring beans.

Running midPoint from IDEA

If you want to run midPoint from within IDEA directly, follow the below steps cautiously:

  1. Make sure you have done a full build apriori, from the root parent project building/installing all components
  2. Create a Java Application "Run Configuration" that is set to run the class "com.evolveum.midpoint.web.boot.MidPointSpringApplication"
  3. For VM options, use: "-Dserver.port=8080 -Xms768m -Xmx2048m -Dmidpoint.home=/path/to/midpoint-home -Dmidpoint.nodeId=node1"
  4. In the Maven Project tool window, expand the "Profiles" node and make sure only "ide" and "tomcat" are selected. All other profiles MUST be unchecked.

Other development tasks

Connecting to midPoint H2 Database

  1. In the Database tool window, create a Data Source configuration based on H2 with the following settings

Developer's setup

Setup Copyright Notices

Select File | Settings | Editor | Copyright | Copyright Profiles (1) and create a new profile ((2) called e.g. midPoint) like this:

Use the following copyright text (in (3)):

Copyright (C) 2010-${today.year} Evolveum and contributors

This work is dual-licensed under the Apache License 2.0
and European Union Public License. See LICENSE file for details.

Then select midPoint in the Default project copyright in the File | Settings | Editor | Copyright. Also consider switching off Add blank line after in File | Settings | Editor | Copyright | Formatting.

Dummy connectors and tests

Tests using dummy connectors will fail with "Error importing src\test\resources\common\resource-dummy.xml" during initialization. This is caused by IDEA-maven integration. While Maven puts JARs of other modules on the classpath, IDEA puts classes directories instead (from target directory). This is not good for connector modules that work only in JAR form because of expected metadata.
To run such tests directly in IDEA, set the modules dummy-connector and dummy-connector-fake as ignored (in icf-connectors module). Right-click on the modules, select Maven -> Ignore projects. Then reimport the Maven project unless you use auto-import. Don't let IDEA to remove the modules from the project structure, otherwise midPoint won't build in IDE.
What we need is this:

Tests run OK, we can check the classpath by clicking on the top-level suite (1), then on the first grayed (shortened) line in the console (2, not displayed in the picture), and searching for "dummy" (3). While the insufficient classes directories are still there (perhaps because we didn't remove the modules from IDEA project), the important thing is that connectors are also added in JAR form (4). This does not happen if the two submodules are not ignored.

Fixing dependencies after upgrades

This example documents situation typical after Spring Boot upgrade, but it can happen with any dependency changes. This may also be a genuine problem with Maven POM, but not necessarily. For example:

First we have to find out what uses the old spring-core. For whatever reason as of IDEA 2020.1 it is not possible from the list above, not even if you open the dependency and try to find usages of the JAR.

To find the usage of a dependency open the Project structure window (in File menu, or Ctrl+Shift+Alt+S):

Choose libraries (2), click to the list, select the library (3) (you can start typing "aop" to find it faster) and in its context menu choose Find Usages (4). This opens pop-up that reveals that the old library is used in dummy-connector - in our example at least.

Remembering from the section above, this is one of those ignored modules. To fix the libraries, let's unignore it (you may have modules displayed as flat list, this depends on the Maven panel settings):

Now refresh the Maven structure and old duplicate dependencies should be gone.

If there is a genuine problem with Maven dependencies, use mvn dependency:tree -pl <submodule> to figure it out and fix accordingly - e.g. exclude or declare the dependency explicitly with specific version.

  • No labels