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.
- Download java JDK from oracle.com http://www.oracle.com/technetwork/java/javase/downloads/index.html
- Select JDK 8
- Accept license
- select package for your platform
- Continue installation for this platform
- Download IDEA from jetbrains.com http://www.jetbrains.com/idea/download/index.html
- Select the version for your operating system and download Ultimate Edition
- Install IntelliJ IDEA on your computer.
First run of IDEA
There is a very good description of IDEA setup with screenshots contributed by Deepak Natarjan: idea-midpoint-init.pdf (attachment)
- 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.
- On next screen you will be asked for license data. Enter them and continue.
- Agree with license politics of IDEA
- 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.
- Select these Web/JavaEE Technology plugins:
- Bean Validation
- Java EE
- Java Server Pages
- Persistance Frameworks
- Spring Data
- Spring OSGi
- Spring Security
- pring Web Services
- Spring-AOP and @AspectJ
- Web Services
6. Select Application Server Plugin: Tomcat
- HTML Tools
- W3C Validators
8. Select Other plugins:
- Inspection Gadgets
- Maven Integration Extension
- XpathView + XSLT
9. Click Finish
Setup MidPoint in IDEA
- Click File -> New Project
- Select 'Create project from scratch' -> Next
- Fill fields Project name and select Project files location -> Next -> Finish
- When new project is created, click VCS in top menu -> Checkout from Version control -> Git
- Click the '+' icon, fill in https://github.com/Evolveum/midpoint.git -> click OK
- Click on the midpoint repository -> Click Checkout.
- Select root folder of your project -> Click OK on several next screens, this will take a while
- Click on VCS again, select Enable Subversion Checkout Control -> OK
- In bottom menu, click on Event Log -> Click on the Settings Icon in left menu
- In AspectJ Group, Select 'No popup' option -> OK
- Now you'll need to install Maven 3 from http://maven.apache.org/download.html.
- On top menu, click Run -> Edit Configurations
- Click on '+' icon and select Maven
- In Parameters Section, choose your working directory, put 'clean install' in command line and 'default' in Profiles. Name your configuration as well.
- Click on General options. Unselect 'Use project settings' and in 'snapshot update policy' add value 'Do Not Update'.
- You may also need to set Maven home directory either to your M2_HOME classpath variable or override it to maven installation folder.
- In Runner option panel, unselect 'Use project settings' and mark 'Skip tests' value. Click OK.
- 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.
- Download and install Tomcat 7 from http://tomcat.apache.org/index.html
- To run midpoint from IDEA, you will need to create user configuration. Click Run -> Edit Configurations.
- Click on '+' button in upper left corner of the screen, choose Tomcat -> Local.
- Name your configuration, then click on 'Configure' button located left to Application Server option.
- Edit Tomcat home and Tomcat base directory. -> OK
- Check the 'Start browser' option and type 'http://localhost:8080/midpoint/login' in startup page. -> OK.
- 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.
- From the command-line, run the build once: mvn[w] clean package
- Go to the infra/schema project and open module settings (right click and select Open Module settings or press F4)
- In the "Sources" tab click on "target" and uncheck the "Excluded" mark (in the "Mark as" bar)
- Expand "target/generated" and mark "target/generated/cfx" as "Sources"
- Mark all other sub-directories of "target" as "Excluded" (classes, cxf-codegen-plugin-markers, maven-archiver, ...)
- Repeat steps 1~4 for the model-client project.
- Click OK
Running midPoint from IDEA
If you want to run midPoint from within IDEA directly, follow the below steps cautiously:
- Make sure you have done a full build apriori, from the root parent project building/installing all components
- Create a Java Application "Run Configuration" that is set to run the class "com.evolveum.midpoint.web.boot.MidPointSpringApplication"
- For VM options, use: "-Dserver.port=8080 -Xms768m -Xmx2048m -Dmidpoint.home=/path/to/midpoint-home -Dmidpoint.nodeId=node1"
- 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.
Connecting to midPoint H2 Database
- In the Database tool window, create a Data Source configuration based on H2 with the following settings
Setup Copyright Notices
Select Settings -> Editor -> Copyright -> Copyright Profiles and create a new profile (called e.g. midPoint) like this:
Use the following copyright text:
Then select midPoint in the "Default project copyright" in the Settings -> Editor -> Copyright panel.
- 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.
- Set the modules dummy-connector and dummy-connector-fake as ignored (in icf-connectors module). Right-click on the modules, select Maven -> Ignore projects. This is needed because of an issue with IDEA-maven integration. IDEA ignores maven build instructions and provides these modules on a classpath in a different form than the test code expects them. The test code then cannot find Dummy connector and fails. (But don't let IDEA to remove the modules from the project structure, otherwise midPoint won't compile.)