Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. git clone http://git-wip-us.apache.org/repos/asf/kafka.git kafka

...

  1. ./sbt update

Table of Contents
maxLevel3

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

...

  1. Select the source directories you want, at least:
    1. core/src/main/scala
    2. core/src/test/scala/unit

...

  1. I had to also add the 2.9.1 scala library by choosing Add External Jar and choosing that library

You should be able to run unit tests or the kafka server or other command line apps through eclipse for debugging. To do this right-click the class you want to run and select

    1. Run as...<Unit Test|Scala Application>
    2. By default log4j will not be configured correctly. To fix this go to your run target and under Classpath choose Advanced... and then Add Folders, and the folder config/

Eclipse Setup With SBT Eclipse Plugin

The following steps assume you have the kafka source and installed the Eclipse Scala IDE, as stated in the Eclipse Setup section above.

...

Code Block

resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.8.5")

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.2.0")

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.1")

...

  • 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.

...

Code Block

[info] About to create Eclipse project files for your project(s).
[info] Successfully created Eclipse project files for project(s):
[info] kafka-perf
[info] hadoop-consumer
[info] kafka-java-examples
[info] kafka
[info] hadoop-producer
  •  

  • Note that the source folder structure may need to be fixed manually : see 
    Jira
    serverASF JIRA
    serverId5aa69414-a9e9-3523-82ec-879b028fb15b
    keyKAFKA-4617

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

    ...

      1. <kafka.project.dir>. Eclipse will find the projects generated by the previous command

    ...

      1. ;

    ...

      1. Select the projects you want to import

    ...

      1. ;

    ...

    You should see the projects you have imported

    ...

    . For running unit tests and Kafka broker refer to the previous section.


    Image AddedOnce you have your projects in place, you will be able to run/debug any of the applications from eclipse.


    Info

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

    Intellij Setup

    ...

    1. git clone http://git-wip-us.apache.org/repos/asf/kafka.git kafka

    ...

    1. ./sbt update

    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>

    ...