kafka源码编译及开发环境搭建

1.安装gradle

1.gradle各版本下载跟路径
    https://services.gradle.org/distributions/
2.我们这里下载和kafka 2.3.1版本匹配的gradle版本,5.4.1
    https://services.gradle.org/distributions/gradle-5.4.1-bin.zip
3.解压
    cd /users/yyj/soft
    tar xvzf gradle-5.4.1-bin.zip
4.配置gradle环境变量,vi /etc/bashrc,添加如下配置:
    GRADLE_HOME=/users/yyj/soft/gradle-5.4.1 
    export PATH="$GRADLE_HOME/bin:$PATH"  
5.验证并查看gradle版本
    gradle -version 

输出以下信息表示成功:

Gradle 5.4.1

Build time:   2019-04-26 08:14:42 UTC
Revision:     261d171646b36a6a28d5a19a69676cd098a4c19d

Kotlin:       1.3.21
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_131 (Oracle Corporation 25.131-b11)
OS:           Mac OS X 10.12.6 x86_64    

2.源码下载根路径地址

http://kafka.apache.org/downloads
当前最新版本为2.3.1,如下图所示:
kafka源码编译及开发环境搭建_第1张图片
我这里下载版本为最新版本,2.3.1
http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.3.1/kafka-2.3.1-src.tgz

3.解压文件

tar xvzf kafka-2.3.1-src.tgz

4.编译kafka源码

1.进入源码根目录执行以下命令构造idea项目:

gradle idea
输出以下信息表示成功:
> Configure project :
Building project 'core' with Scala version 2.12.8
Building project 'streams-scala' with Scala version 2.12.8

> Task :idea
Generated IDEA project at file:///Users/haizhi/yyj/github/kafka231/kafka231.ipr

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 5s
31 actionable tasks: 31 executed

5.导入源码到idea

你可能感兴趣的:(Kafka,Kafka源码,Kafka源码开发环境搭建,kafka,gradle)