In this article is shown how to setup Jetbrains IntelliJ IDEA for debug/develop Apache MiNiFi tool.
Jetbrains Intellij IDEA is a powerful IDE but sometimes is a little bit complicated of setting up, in particular when the upstream project doesn’t have clear instructions about the development using this kind of IDE’s.
Working with GitHub
The first thing to do is forking Apache MiNiFi project from official Apache Github mirror: https://github.com/apache/nifi-minifi
The usual way of working is cloning the owned fork locally and add the remote source repository for maintaining in sync with original repo.
$ git clone email@example.com:javiroman/nifi-minifi.git $ git remote -v origin firstname.lastname@example.org:javiroman/nifi-minifi.git (fetch) origin email@example.com:javiroman/nifi-minifi.git (push) $ git remote add upstream firstname.lastname@example.org:apache/nifi-minifi.git $ git remote -v origin email@example.com:javiroman/nifi-minifi.git (fetch) origin firstname.lastname@example.org:javiroman/nifi-minifi.git (push) upstream email@example.com:apache/nifi-minifi.git (fetch) upstream firstname.lastname@example.org:apache/nifi-minifi.git (push) $ git fetch upstream $ git log commit de08ea2adedcab9c5055dea793deee3a49aec29d (HEAD -> master, upstream/master, origin/master, origin/HEAD) Author: Sapin Amin <email@example.com> Date: Tue Jan 14 15:02:21 2020 -0800 MINIFI-522 : Fixed Access denied to: http://jcenter.bintray.com which caused Failed to execute goal on project minifi-standard-nar This closes #182. Signed-off-by: Aldrin Piri <firstname.lastname@example.org>
Now we are going to create a feature branch for working with our new awesome feature!
$ git checkout -b my-awesome-feature Switched to a new branch 'my-awesome-feature'
Time for importing into IntelliJ IDEA
In this article we are going to work with IntelliJ IDEA Ultimate version (the instructions for the community edition presumably are the same). Many thanks to Jetbrains for making available the Ultimate version to Apache committers: https://blog.jetbrains.com/blog/2019/05/30/jetbrains-supports-the-apache-software-foundation/
We have to import the brand new cloned repository as “Import project from external model” -> Maven.
A few minutes later you will have the IDE view with your project viewer fully indexed.
After that, you have to take into account one important advice: Try to use Maven and JDK from your system not the dispatched with IDEA IDE. The system used in this article is:
$ cat /etc/fedora-release Fedora release 30 (Thirty) $ mvn -version Apache Maven 3.5.4 (Red Hat 3.5.4-5) Maven home: /usr/share/maven Java version: 1.8.0_242, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-220.127.116.11.b08-0.fc30.x86_64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.5.6-100.fc30.x86_64", arch: "amd64", family: "unix" $ java -version openjdk version "1.8.0_242" OpenJDK Runtime Environment (build 1.8.0_242-b08) OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
We are now ready for building MiNiFi artifacts: We have to clean and install using the integrated Maven Plugin controls.
We are ready for running Apache MiNiFi step-by-step within the IDE. The first step is identify the MiNiFi entry point class. The “main” method of RunMiNiFi.java class from minifi-bootstrap sub-project is the one we are looking for.
Clicking the green arrow beside main method we can access to “Edit Run Configuration: RunMiNiFi“.
Remember setup the Working Directory from Run Configurations to the target folder of minifi-assembly sub-project: In this folder you have the configuration folder for MiNiFi and the run-time libraries.
You have to setup the MINIFI_HOME environment variable pointing out to the same place that the working folder.
Finally enter the program argument “Run” for running MiNiFi properly. And is specially important check the box “Include dependencies with Provided scope“.
In order to run MiNiFi step-by-step, put a breakpoint in the main method for instance.
Run debug execution and everything is ready!
Many thanks to Kevin Doran for this reference article:
Many thanks to Apache NiFi Slack people: