1.kafka源码编译
发布日期:2021-07-30 03:26:37 浏览次数:2 分类:技术文章

本文共 4170 字,大约阅读时间需要 13 分钟。

kafka源码编译

1.准备环境

1.java环境

检查java版本,1.8

java -version

2.scala环境

检查scala版本,2.11.8

scala -version

3.gradle环境

检查gradle版本

gradle -version

在这里插入图片描述

4.kafka

这里下载0.11.3,gradle版本也要选择低版本,4.10.2可以编译成功,5.6,6.8都编译失败

在这里插入图片描述

2.编译kafka

解压kafka-0.11.0.3-src.tgzF:\resources>cd kafka-0.11.0.3-srcF:\resources\kafka-0.11.0.3-src>gradle idea

1.报错信息1

F:\resources\kafka-0.11.0.3-src>gradle ideaFAILURE: 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.orgDeprecated 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_warningsBUILD 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.11FAILURE: 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.orgDeprecated 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_warningsBUILD 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.11FAILURE: 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.
(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.orgDeprecated 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_warningsBUILD 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 :ideaGenerated IDEA project at file:///F:/resources/kafka-0.11.0.3-src/kafka-0.11.0.3-src.iprDeprecated 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_warningsBUILD SUCCESSFUL in 7s21 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 运行相关配置
connect Kafka Connect运用用户快速定义并实现各种Connector(File,Jdbc,Hdfs等),大批量数据导入导出方便
core kafka服务实例的代码,scala语言开发,实现了集群管理,分区副本管理,消息存储和消息获取,网络通信等功能
docs 文档
examples 使用生产者消费者demo
gradle gradle构建相关
streams kafka 流相关,替代storm等
tests 测试脚本
tools 工具类,查看生产者性能等

转载地址:https://blog.csdn.net/u010895512/article/details/118252866 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:2.调试kafka源码
下一篇:搭建java环境

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2024年03月31日 12时52分16秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章