Skip to content

IntelliJ IDEA tutorial

IntelliJ IDEA by JetBrains is the Interactive Development Environment (IDE) used by most of the Egeria developers. The community edition is free to use and covers all the function needed by an Egeria developer.

See the overview video of IntelliJ on its homepage.

Managing your IntelliJ environment

Installing Intellij

Link to the download page and follow the instructions.

Start up IntelliJ.

Set up Java ...

Validate that the project is set up with the right level of Java - you need Java 11. Select File and then Project Structure.... When the wizard opens select Project and ensure the SDK is Java 11.

Set Java level

Set up Maven ...

Set up Maven to the version that you downloaded by selecting Preferences ... from the IntelliJ IDEA menu and then Build, Execution, Deployment followed by Build Tools followed by Maven in the left-hand menu of the resulting wizard. Ensure the Maven Home Directory points to a level of Maven that is at least version 3.5.0.

Set up Maven level

The three dots after the directory name enables you to select your Maven install directory.

Ensure you have enough memory ...

Update your memory settings for IntelliJ to ensure you have at least 2GB of memory. This is the option Change Memory Settings that is under the Help menu. In some editions it is nested under Diagnostics.

Memory Settings on Help Menu

Check your lombok setup

Egeria makes use of Project Lombok . If using JetBrains IntelliJ IDEA ensure it has the required plugin configured .

Don't detect generated sources

Before running a Maven build, please choose Don't detect from the Generated sources folders dropdown in Preferences -> Build, Execution, Deployment -> Build Tools -> Maven -> Importing. This will avoid triggering a duplicate classes build error caused by the delomboked sources folders being added as source folders for the Maven module.

If this wasn't set when your project was initially setup, you may find that delombok directories are already present in IntelliJ's source path for some modules, leading to errors with duplicate classes.

To check for any modules still refering to delombok you can run this at the command line, from your top-level source tree:

Find any existing delombok source entries in IntelliJ

find . -name '*.iml' | xargs -n50 grep -y delombok

If you find any hits such as:

./open-metadata-implementation/access-services/data-engine/data-engine-api/data-engine-api.iml:      <sourceFolder url="file://$MODULE_DIR$/target/delombok" isTestSource="false" />

then either remove those lines without IntelliJ running, or go into File -> Project Structure -> Modules, and remove target/delombok from the Source Folders list

Explanation: in addition to importing module defintions from the Maven pom.xml, IntelliJ also tries to look for any generated source. It finds the delombok directory, causing duplicates: in fact we only use this directory for generating Javadoc of lombok-enabled modules. Switching the setting / removing these source folders prevents these duplicate classes.

Loading Egeria into IntelliJ IDEA

Once you have a branch of a git repository you can load the contents into IntelliJ.

Go to the File menu and select Open

File->Open menu

Then select the top-level directory that was created when you cloned the git repository.

Select clone directory

You may be warned about loading egeria in which case select Trust Project:

Trust Project

If asked which build approach to use, select Maven:

Import Maven Project

IntelliJ will then start reading the git repository and creating a project. This may take a few minutes so be patient.

Validate that the project is set up with the right level of Java - you need Java 11. Select File and then Project Structure.... When the wizard opens select Project and ensure the SDK is Java 11.

Set Java level

Building Egeria in IntelliJ IDEA

The build process is different for each git repository. Click on the table for the repository that you are building:

Building egeria.git

Maven is accessed from a sidebar menu in IntelliJ.

Maven Sidebar

When you click on the Maven label, a panel opens with the list of modules in the git repository is displayed.

Chose the build option for your work ...

The egeria.git repository has a top-level pom file so all of the modules can be built using one command.

Select the M button at the top of the maven panel for Execute Maven Goal.

Maven build opens

Then the Execute Maven Goal dialog box opens to enter your command clean install command.

The egeria.git repository has a top-level pom file so all of the modules can be built using one command.

Select the M button at the top of the maven panel for Execute Maven Goal.

Maven build opens

Then the Execute Maven Goal dialog box opens to enter your command clean install -P quick -D skipFVT. This skips all of the verification of the project files and running tests. It is suitable for development projects (such when running the dojo). However, if you are experiencing problems with building this repository, use the full build option to verify the project directories.

If you are making small changes, you may wish to simply rebuild a single module.

Goto the maven sidebar panel and find the module you are interested in. Open up the content for the module and then the lifecycle folder.

Maven module options

First double-click on clean and the build of that module runs.

Once the clean is complete, double-click on install and the build of that module starts.

Note: this option does not rebuild the assembly and so if you are using the OMAG Server Platform from the assembly to test your changes, you may need to do a full build to incorporate your change into the platform.

The build kicks off in a new pane (typically at the bottom of your IntelliJ window).

The build can take 15 minutes to over an hour depending on the build method and speed/load on your machine. However eventually you will see the message:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 54:54 min
[INFO] Finished at: 2020-01-29T09:33:17Z
[INFO] Final Memory: 171M/3510M
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

Building egeria-samples.git

Maven is accessed from a sidebar menu in IntelliJ.

Maven Sidebar

When you click on the Maven label, a panel opens with the list of modules in the git repository is displayed. The maven:

The egeria-samples.git repository does not have a top-level pom file. Each sample is built separately.

Go to the module of the sample that you are interested in. Open up the content for the module and then the lifecycle folder.

Maven module options

First double-click on clean and the build of that module runs.

Once the clean is complete, double-click on install and the build of that module starts.

The build kicks off in a new pane (typically at the bottom of your IntelliJ window).

The build takes a few minutes depending on the speed/load on your machine. However eventually you will see the message:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 54:54 min
[INFO] Finished at: 2020-01-29T09:33:17Z
[INFO] Final Memory: 171M/3510M
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

Building egeria-dev-projects.git

Maven is accessed from a sidebar menu in IntelliJ.

Maven Sidebar

When you click on the Maven label, a panel opens with the list of modules in the git repository is displayed. The maven:

The egeria-dev-projects.git repository has a top-level pom file so all of the modules can be built using one command.

Select the M button at the top of the maven panel for Execute Maven Goal.

Maven build opens

Then the Execute Maven Goal dialog box opens to enter your command clean install and press Execute.

The build kicks off in a new pane (typically at the bottom of your IntelliJ window).

The build can take a few minutes depending on the speed/load on your machine. However eventually you will see the message:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 54:54 min
[INFO] Finished at: 2020-01-29T09:33:17Z
[INFO] Final Memory: 171M/3510M
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

Using maven rather than using the IntelliJ build?

While you are working on code in IntelliJ, it will be continuously rebuilding your code so that it is discovering syntax other coding errors as you type. This is useful in getting a first pass of your code.

However, IntelliJ does not understand the egeria structure - only Maven does, so the Maven build is important to to verify your changes are OK at the project level.

Installing Egeria

If your development work is using the main Egeria libraries rather than developing its contents, you may wish to install Egeria into a more convenient location on your local disk.

Click on the Terminal tab - typically at the bottom of your IntelliJ window - to open the terminal window. The working directory is positioned at the top of your project.

Terminal Tab

The egeria build process creates the distribution files for Egeria in the open-metadata-distribution module. To see its contents, use the following cd command to change to the target directory:

cd open-metadata-distribution/open-metadata-assemblies/target
List the files:
ls -l
The name of the files is determined by the release level of the code that you downloaded from GitHub. In this example, the release is egeria-3.8-SNAPSHOT. The files in this list will also change as Egeria develops.
antrun                                                  egeria-3.8-SNAPSHOT-distribution
archive-tmp                                             egeria-3.8-SNAPSHOT-distribution.tar.gz
egeria-3.8-SNAPSHOT-deploy                              open-metadata-assemblies-3.8-SNAPSHOT-javadoc.jar
egeria-3.8-SNAPSHOT-deploy.tar.gz                       open-metadata-assemblies-3.8-SNAPSHOT-sources.jar
The install image tar file is {{release}}-distribution.tar.gz or egeria-3.8-SNAPSHOT-distribution.tar.gz in this example.

Create a directory for the install and copy the tar file into it. The two commands shown below create an install directory at the same level in the file system as the egeria build library and then copies the egeria distribution file into it.

mkdir ~/egeria-install
cp egeria*-distribution.tar.gz ~/egeria-install

These next commands change to the new directory and lists its contents.

cd ~/egeria-install
ls
egeria-3.8-SNAPSHOT-distribution.tar.gz

It is now possible to unpack the tar file.

tar -xf egeria*-distribution.tar.gz
A new directory is created called egeria-omag-3.8-SNAPSHOT. Change to this new directory and list its contents as shown below.

cd egeria-omag*
ls
LICENSE                 content-packs           samples                 user-interface
NOTICE                  keystore.p12            server                  utilities
conformance-suite       sample-data             truststore.p12

As before, you may notice different files as Egeria evolves.

Under server is a directory for the OMAG Server Platform that is used to run open metadata and governance services. This is the server-chassis-spring-3.8-SNAPSHOT.jar.

ls server
lib             server-chassis-spring-3.8-SNAPSHOT.jar
The lib directory is where the jar files for connectors, samples and new registered services are installed. The initial list includes the connectors that are located in the egeria.git repository.
ls server/lib
audit-log-console-connector-3.8-SNAPSHOT.jar
audit-log-event-topic-connector-3.8-SNAPSHOT.jar
audit-log-file-connector-3.8-SNAPSHOT.jar
audit-log-slf4j-connector-3.8-SNAPSHOT.jar
avro-file-connector-3.8-SNAPSHOT.jar
basic-file-connector-3.8-SNAPSHOT.jar
cohort-registry-file-store-connector-3.8-SNAPSHOT.jar
configuration-encrypted-file-store-connector-3.8-SNAPSHOT.jar
configuration-file-store-connector-3.8-SNAPSHOT.jar
csv-file-connector-3.8-SNAPSHOT.jar
data-folder-connector-3.8-SNAPSHOT.jar
discovery-service-connectors-3.8-SNAPSHOT.jar
dynamic-archiver-connectors-3.8-SNAPSHOT.jar
elasticsearch-integration-connector-3.8-SNAPSHOT.jar
files-integration-connectors-3.8-SNAPSHOT.jar
governance-action-connectors-3.8-SNAPSHOT.jar
governance-services-sample-3.8-SNAPSHOT.jar
graph-repository-connector-3.8-SNAPSHOT-jar-with-dependencies.jar
inmemory-open-metadata-topic-connector-3.8-SNAPSHOT.jar
inmemory-repository-connector-3.8-SNAPSHOT.jar
kafka-integration-connector-3.8-SNAPSHOT.jar
kafka-open-metadata-topic-connector-3.8-SNAPSHOT.jar
omrs-rest-repository-connector-3.8-SNAPSHOT.jar
open-lineage-janus-connector-3.8-SNAPSHOT.jar
open-metadata-archive-directory-connector-3.8-SNAPSHOT.jar
open-metadata-archive-file-connector-3.8-SNAPSHOT.jar
open-metadata-security-samples-3.8-SNAPSHOT.jar
openapi-integration-connector-3.8-SNAPSHOT.jar
openlineage-integration-connectors-3.8-SNAPSHOT.jar
spring-rest-client-connector-3.8-SNAPSHOT.jar

Copy the jar files for any additional connectors not added by default into the lib directory. The connectors available for Egeria are listed in the Connector Catalog.

Developing new function with IntelliJ IDEA

Creating a new project

To add a new project to intellij, select New then Project from the File top-level menu of IntelliJ.

Step 1

Select Java then set up the project SDK by selecting your Java 11 installed JDK and then click the Next button. If this is the first time you are using IntelliJ you may need to click on the New... button and navigate to your install directory.

Step 2

Leave the Create project from template option blank and simply click the Next button.

Step 3

Add the name of the project in Project name and the directory where you want the project files to be stored in Project location.

Step 4

Click on the Finish button. If the directory is new, you may get this pop-up to confirm that the directory should be created. Click OK.

Step 5

Once the wizard completes IntelliJ will open up your new project, ready to begin coding. The src directory is where your code will go.

Step 6

Creating a new java package

To add a new Java package to your project, right-mouse click on the java directory.

Step 1

Select New then Package on the sub menu.

Step 2

A pop-up box appears asking for the name of the package. Enter your new package name and press the OK button. Java package names are in lowercase and are dot (.) separated.

Step 3

The new package appears under src in the project list.

Creating a new java class

To add a new Java class to your project, right-mouse click on the package name and select New then Java Class on the sub menu.

Step 1

A pop-up box appears asking for the name of the class. Enter your new class name and press the OK button.

Step 2

The new class appears in the project list and the source file is open in the editor.

Step 2

Adding changes to Git

Any changes, additions and deletions that you make to the files under the git repository directory are automatically detected by git. It is possible to add these changes to your clone using the Add option on the Git right-mouse menu.

Git->Add option

Back to top