1、源码地址
http://archive.apache.org/dist/kafka/0.10.0.0/kafka-0.10.0.0-src.tgz
2、环境准备
centOS
gradle 下载地址 https://services.gradle.org/distributions/gradle-3.1-bin.zip 安装请参考 这里 。注意要安装3.1版本,如果安装1.1版本可能会出错。
Scala
Java
3、生成idea项目文件
解压kafka-0.10.0.0-src.tgz
进入目录,执行gradle idea
4、问题:
执行gradle idea时,报错
[root@bigdata01 kafka-0.10.0.0-src]# gradle idea
Starting a Gradle Daemon (subsequent builds will be faster)
Building project 'core' with Scala version 2.10.6
FAILURE: Build failed with an exception.
* Where:
Build file '/opt/bigdata/kafka/kafka-0.10.0.0-src/build.gradle' line: 230
* What went wrong:
A problem occurred evaluating root project 'kafka-0.10.0.0-src'.
> Failed to apply plugin [class 'org.gradle.api.plugins.scala.ScalaBasePlugin']
> No such property: useAnt for class: org.gradle.api.tasks.scala.ScalaCompileOptions
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 22.997 secs
解决方法:vim kafka-0.10.0.0-src/build.gradle文件
添加如下行
ScalaCompileOptions.metaClass.daemonServer = true
ScalaCompileOptions.metaClass.fork = true
ScalaCompileOptions.metaClass.useAnt = false
ScalaCompileOptions.metaClass.useCompileDaemon = false
执行gradle idea时,报错
FAILURE: Build failed with an exception.
* Where:
Build file '/opt/bigdata/kafka/kafka-0.10.0.0-src/build.gradle' line: 48
* What went wrong:
Could not compile build file '/opt/bigdata/kafka/kafka-0.10.0.0-src/build.gradle'.
> startup failed:
build file '/opt/bigdata/kafka/kafka-0.10.0.0-src/build.gradle': 48: unable to resolve class ComponentSelection
@ line 48, column 19.
rules.all { ComponentSelection selection ->
^
1 error
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 9.076 secs
我之前安装的是1.1版本的Gradle。换成3.1版本后,问题解决。