Eclipse setup

Install and prepare Eclipse

  • Download and install Eclipse (Indigo or Juno is recommended);
  • Install Scala 2.10.x IDE plugin as described here. Make sure to get the right bundle / update site according with your Eclipse version;
  • Install IvyIDE plugin as described here. This will allow to automatically create classpath containers starting from ivy files;

Checkout Kafka source

Generate Eclipse project files

  • cd <kafka.project.dir>

  • Bootstrap gradle wrapper with: gradle
  • Generate the eclipse projects with: ./gradlew eclipse. This command will create eclipse projects for every project defined in Kafka. 

  • Note that the source folder structure may need to be fixed manually : see  KAFKA-4617 - Getting issue details... STATUS

Create the Eclipse workspace

  • Open Eclipse and create a new workspace;
  • Import the generated project (File -> Import -> General -> Existing Projects into Workspace)
    1. Navigate to the <kafka.project.dir>. Eclipse will find the projects generated by the previous command;
    2. Select the projects you want to import;

You should see the projects you have imported. For running unit tests and Kafka broker refer to the previous section.



You will need regenerate the projects and refresh eclipse every time there is a change in the projects dependencies. In other words, you need to run ./gradlew eclipse and refresh eclipse.

NOTE - update for Eclipse 3.7.x Oxygen, scala-ide 4.7.1RC3 and Scala 2.12

After generating the projects with

gradle -PscalaVersion=2.12
./gradlew -PscalaVersion=2.12 eclipse --refresh-dependencies

In Eclipse you need some manual tweaking to get rid of the build errors :

  • remove the duplicate java src path entry from  core 
  • remove all 'test' library entries in the projects : core/streams/streams-scala

then, break the build cycle

  • remove the `test-utils` project dependency from streams
  • add the test-utils source folders `test-utils/src/main/java` and `test-utils/src/test/java` to the streams project 


Intellij Setup

Install and prepare IntelliJ

  • Download and install IntelliJ;
  • Install the IntelliJ IDEA Scala Plugin (Menu Item File | Settings -> Plugins -> Browse Repositories -> Search for Scala);

Checkout Kafka source

Update libraries and generate IntelliJ project files

  • cd <kafka.project.dir>
  • gradle
  • ./gradlew idea

Create IntelliJ workspace

  • Open Intellij and click open project pointing to <kafka.project.dir>
  • No labels

5 Comments

  1. Anonymous

    Seems that "./sbt idea" is not correct and instead should be "./sbt gen-idea"

    --Federico

    1. Ok, mistake removed...thank you very much

  2. Anonymous

    I just wanted to comment on your blog and say I really enjoyed reading your blog here. It was very informative and I also digg the way you write! Keep it up and I'll be back soon to find out more mate.Sound Box

  3. If you just checked out the code, you don't have the gradle wrapper library and you'll get an error message after running `./gradlew`:

    "Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain"

    To fix it you need to run `gradle wrapper` first which will download the gradle wrapper (you need to have gradle >= 1.7 installed locally).

     

    From developers perspective it would be cool to check-in the wrapper library in the sources as recommended in the gradle documentation (https://www.gradle.org/docs/current/userguide/gradle_wrapper.html):

    gradlew
    gradlew.bat
    gradle/wrapper/
    gradle-wrapper.jar
    gradle-wrapper.properties
    All of these files should be submitted to your version control system. This only needs to be done once.

    I agree it's not cool checking-in jar files, but it's only 50Kb and you don't need to install gradle locally yourself then.

  4. Based on the above instruction, we will still need to specify the config file and classpath location for a debug startup.
    The broker cannot start because we need to provide the locations for log4j configuration and broker property file. The correct is to:

    1) Add all generated jars into classpath using configuration menu.
    2) Specify which class is being loaded as "main" - for bootstrap -it's kafka.Kafka
    3) The VM argument should be - -Dlog4j.configuration=file:#DIRECTORY_PATH#/kafka_2.11-2.0.0/config/log4j.properties
    4) Programme Argument Should be - #DIRECTORY_PATH#/kafka_2.11-2.0.0/config/server.properties