当前位置:   article > 正文

1.kafka源码编译_kafka编译

kafka编译

kafka源码编译

1.准备环境

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

java -version
  • 1

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

scala -version
  • 1

3.gradle环境
检查gradle版本

gradle -version
  • 1

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
  • 2
  • 3
  • 4

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

提示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

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

提示504行org.scoverage

把 build.gradle 文件29行

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

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

再次降低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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

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工具类,查看生产者性能等
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/288964?site
推荐阅读
相关标签
  

闽ICP备14008679号