Eclipse setup (without SBT eclipse plugin)

Install and prepare Eclipse

Checkout Kafka source

You can also do that within Eclipse using the Git plugin. This is a built-in plugin with Juno while you have to install separately with Indigo.

Update the libraries and generate ivy configuration files

Create the Eclipse workspace

Probably Eclipse will prompt you about the upgrade of the Scala plugin. You can ignore that warning.

If the selected directory is right, you will see something like “The wizard will automatically configure the JRE and the project layout..."

Sources and dependencies

At this point your Eclipse project  doesn't have any source folder configured. The <kafka.project.dir> contains several sub-projects, a core and other related modules. Each of them has source folders and dependencies that you must add in order to compile and run tests. The core module is the most important because it's the broker itself; as consequence of that its section (below) is longer than the others

core

Open the project properties again, select Java build path: make sure that, in “Order and Export” tab, the zkclient-20120522.jar is in list before the generated ivy container entry.

Now you should have two source folders, several classpath containers and no compilation errors. If so, you can run unit tests by right clicking the core/src/scala/unit source folder and select Run as -> Scala JUnit Test

You can also run a Kafka instance directly within Eclipse. To do that, firstly you need two configuration files (server.properties and log4j.properties)

You already have those configuration files in your Eclipse, under the config directory. However, those are supposed to be used as template and are under version control, so if you are going to play with them, is better to make a copy elsewhere.

For running a broker:

You should see in Eclipse console the following output:

...
INFO New leader is 0 (kafka.server.ZookeeperLeaderElector$LeaderChangeListener)
INFO Registered broker 0 at path /brokers/ids/0 with address gxserver:9092. (kafka.utils.ZkUtils$)
INFO [Kafka Server 0], started (kafka.server.KafkaServer)
contrib

The contrib module is a dependent module of kafka and therefore the ivy generared files contain a dependency that doens't exists in Ivy repository (the kafka jar). So first of all you need to edit those files (ivy-0.8-SNAPSHOT.xml)under the target directory of each contrib module and remove the following line:

<dependency org="org.apache" name="kafka_2.8.0" rev="0.8-SNAPSHOT" conf="compile->default(compile)"/>
examples and perf

If you want to setup those modules too, you can follow the same steps of the contrib module, they have a similar structure. One important difference is that examples and perf modules don't declare unmanaged dependencies.

Eclipse setup (with SBT eclipse plugin)

The following steps assume you completed the first two steps of the setup described above (install, prepare Eclipse and checkout Kafka source).

Generate Eclipse project files

Create the Eclipse workspace

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, every time you run ./sbt update, you need to run ./sbt eclipse and refresh eclipse.

Intellij Setup

Install and prepare IntelliJ

Checkout Kafka source

Update libraries and generate IntelliJ project files

Create IntelliJ workspace