1.kafka源码编译

kafka源码编译

1.准备环境

1.java环境
检查java版本,1.8

java -version

2.scala环境
检查scala版本,2.11.8

scala -version

3.gradle环境
检查gradle版本

gradle -version

gradle各版本下载地址
gradle依赖
johnrengelman.shadow插件版本
在这里插入图片描述

4.kafka

kafka各版本下载地址

这里下载0.11.3,gradle版本也要选择低版本,4.10.2可以编译成功,5.6,6.8都编译失败
在这里插入图片描述

2.编译kafka

解压kafka-0.11.0.3-src.tgz

F:\resources>cd kafka-0.11.0.3-src
F:\resources\kafka-0.11.0.3-src>gradle idea

1.报错信息1

F:\resources\kafka-0.11.0.3-src>gradle idea

FAILURE: Build failed with an exception.

* Where:
Build file 'F:\resources\kafka-0.11.0.3-src\build.gradle' line: 140

* What went wrong:
A problem occurred evaluating root project 'kafka-0.11.0.3-src'.
> Plugin with id 'findbugs' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

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

BUILD FAILED in 1s

提示kafka-0.11.0.3-src目录下build.gradle的140行,findbugs有问题
当前是6.8版本,更改版本为5.6
重新gradle idea

2.报错信息2

Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :
Building project 'core' with Scala version 2.11.11

FAILURE: Build failed with an exception.

* Where:
Build file 'F:\resources\kafka-0.11.0.3-src\build.gradle' line: 504

* What went wrong:
A problem occurred evaluating root project 'kafka-0.11.0.3-src'.
> Failed to apply plugin [id 'org.scoverage']
   > Could not create an instance of type org.scoverage.ScoverageExtension.
      > You can't map a property that does not exist: propertyName=testClassesDir

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

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.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 25s

提示504行org.scoverage

把 build.gradle 文件29行

 classpath 'org.scoverage:gradle-scoverage:2.1.0'

2.1.0修改为2.5.0,再次执行gradle idea

3.报错信息3

> Configure project :
Building project 'core' with Scala version 2.11.11

FAILURE: Build failed with an exception.

* Where:
Build file 'F:\resources\kafka-0.11.0.3-src\build.gradle' line: 950

* What went wrong:
A problem occurred evaluating root project 'kafka-0.11.0.3-src'.
> org.gradle.api.internal.java.JavaLibrary.<init>(Lorg/gradle/api/artifacts/PublishArtifact;Lorg/gradle/api/artifacts/DependencySet;)V

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

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.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 6s

再次降低gradle版本,由5.6改为4.10.2,gradle-scoverage:2.5.0修改回来2.1.0
再次执行gradle idea

> Configure project :
Building project 'core' with Scala version 2.11.11

> Task :idea
Generated IDEA project at file:///F:/resources/kafka-0.11.0.3-src/kafka-0.11.0.3-src.ipr

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

BUILD SUCCESSFUL in 7s
21 actionable tasks: 21 executed

3.打开idea,导入kafka源码

1.File–setting里面设置gradle
在这里插入图片描述
2.File–setting–plugin,安装scala插件
在这里插入图片描述
3.File–open ,打开kafka源码目录kafka-0.11.0.3-src
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

目录说明
bin启动脚本,启停KafkaServer,创建主题等
checkstyle代码检查配置
clients生产者和消费者代码,新版java语言开发
config运行相关配置
connectKafka Connect运用用户快速定义并实现各种Connector(File,Jdbc,Hdfs等),大批量数据导入导出方便
corekafka服务实例的代码,scala语言开发,实现了集群管理,分区副本管理,消息存储和消息获取,网络通信等功能
docs文档
examples使用生产者消费者demo
gradlegradle构建相关
streamskafka 流相关,替代storm等
tests测试脚本
tools工具类,查看生产者性能等
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值