You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Eclipse Setup

  1. Checkout kafka source
    1. git clone http://git-wip-us.apache.org/repos/asf/kafka.git kafka
  2. Update the libraries:
    1. ./sbt update
  3. Install the eclipse/scala 2.9.x plugin as described here. Make sure to get the right bundle / update site according with your Eclipse version.
  4. Create a new scala project File->New->Scala Project
  5. Set the location to the directory to which you checked out the code and choose a name for the project.
    1. Select the source directories you want, at least:
      1. core/src/main/scala
      2. core/src/test/scala/unit
  6. Add all the libraries in the Libraries tab: core/lib and core/lib_managed
    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.

  1. edit the project/plugins.sbt file by adding the sbteclipse-plugin from Typesafe (last line in the snippet below). Once modified, the file should look like this:
    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")
    
  2. run: ./sbt update
  3. generate the eclipse projects with: ./sbt eclipse. This command will create eclipse projects for every project defined in Kafka. You should have the following output on your console:
    [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
    
  4. In eclipse, use Import -> General -> Existing Projects into Workspace
    1. navigate to the kafka source directory, it should find the projects generated by the previous command.
    2. select the projects you want to import and click Finish
    3. you should see the projects you have imported

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

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 eclipse and refresh eclipse.

Intellij Setup

  1. Checkout kafka source
    1. git clone http://git-wip-us.apache.org/repos/asf/kafka.git kafka
  2. Update the libraries:
    1. ./sbt update
  3. Create IDEA project files:
    1. ./sbt
    2. idea
  4. Install the IntelliJ IDEA Scala Plugin Preferences -> Plugins -> Browse Repositories -> Search for Scala||\
  5. Open Itellij, Open new project, point to your kafka source location.
  • No labels