In an earlier post I provided step-by-step instructions to set up eclipse for Apache Kafka development and code contribution. Over the months I have used eclipse to contribute to the Kafka project I have come across some issues:

  • Frequently, eclipse starts to take forever to build the project and eventually it throws an out-of-memory error. When this happens the only solution is to restart eclipse.
  • From time to time eclipse seems to corrupt my Kafka project to a point that at least I cannot easily recover from it. This has happened a few times, and has made me to start over with a new environment and install and set up eclipse again for Kafka code contribution.
  • The Scala plug-in for eclipse is not super, and does not provide the Java-equivalent level of support and user-friendliness that eclipse provides. For example, it is not easy to watch or evaluate expressions. Also, some code navigation features, such as finding all callers of a method, did not work well for me. It is possible that this Scala plugin contributes to the above issues.

Due to above and other problems I experienced with eclipse, and also the fact that most committers to the project use IntelliJ IDEA for their code contribution work, I started to look into doing a similar set up I described in that earlier article, this time using IntelliJ IDEA. The result is what you see below.

Install Necessary Software

You might have already installed some of these software by following my previous post, but I mention them all here to make it a comprehensive list.

  1. Git
    sudo apt-get update
    sudo apt-get install git
  2. Java
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java8-installer
  3. Gradle
    sudo add-apt-repository ppa:cwchien/gradle
    sudo apt-get update
    sudo apt-get install gradle
  4. Apache Kafka
    git clone https://github.com/apache/kafka.git
    cd kafka/
    gradle
    ./gradlew jar (this lets you run Kafka commands via the terminal)
    ./gradlew idea (this prepares your Kafka folder to be used in IntelliJ IDEA)
  5. IntelliJ IDEA
    Download and install IntelliJ IDEA (the Community edition will do) by following the instruction at this link. While you are going through customizing your IntelliJ IDEA installation, make sure you Install the Scala language support plugin at “Download and install additional plugins” step (“Download featured plugins” window).

    If you, like me, are migrating from eclipse you might want to glance over this.

  6. Load Kafka Projects into IntelliJ IDEA

    At the welcome screen of IntelliJ IDEA select “Open”.

    At the “Open File or Project” window select the Kafka folder created after the git clone command above, and click “OK”.

    At this point, IDEA starts loading the Kafka project and building necessary indexes.

    Loading the project is complete now.

    Unlike eclipse, running or debugging the code inside the IDEA IDE is much easier: you can just provide the command line arguments and run or debug a tool without having to provide all the JVM arguments or any other step we took for eclipse.

    Additional Tips

    For those who, like myself, migrate from eclipse accessing some of the frequently used functionalities of IntelliJ IDEA is not the same. I try to maintain a list here that I, for one, will certainly come back to later. Not that for shortcuts I provide the default key combination.

    • Search in files: Edit -> Find -> Find in Path..., or Ctrl-Shift-F. You can also use the search icon on the far right of the main toolbar. Activate the main toolbar through View -> Toolbar (if not already activated).
    • Go to variable / method definition: Right-Click -> Go To -> GoTo, or Ctrl-B.
    • Navigate back: Navigate -> Back, or Ctrl-Alt-LeftArrow (on Mac, Command-Alt-LeftArrow), or the back button on the toolbar.
    • Delete current line: Ctrl-Y

Join The Discussion

Your email address will not be published. Required fields are marked *