01 源码本地调试环境搭建
1. 从github拉取源码创建本地项⽬
可以拉取github上官⽅代码
2. 配置编译环境
ctrl+alt+shift+s (或菜单)打开项⽬结构,确保jdk版本为1.8,scala版本最好为2.12.73. 源码编译
4、准备运⾏环境
5、编译中遇到的问题
5.1flink 1.18 源码编译 shader 19
编译 Flink Shaded:
- 进入 Flink 源码目录,并切换到相应的 Shaded 版本分支,例如 flink-shaded-193。
- 执行 Maven 命令来编译 Flink Shaded 19 版本:
这将编译 Flink Shaded 19 并生成相应的构建产物mvn clean package -DskipTests
5.2 Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.2:check (validate) on project flink-runtime: You have 3 Checkstyle violations.
-
运行 Checkstyle 检查:
- 在修正了代码风格问题后,你可以单独运行 Checkstyle 插件来检查问题是否已经解决。使用以下 Maven 命令:
mvn checkstyle:check
- 如果之前没有配置 Checkstyle,或者你想使用不同的配置文件,可以通过
-DconfigLocation
参数指定 Checkstyle 配置文件:mvn checkstyle:check -DconfigLocation=checkstyle.xml
- 在修正了代码风格问题后,你可以单独运行 Checkstyle 插件来检查问题是否已经解决。使用以下 Maven 命令:
-
整合到构建流程:
一旦所有的 Checkstyle 违规问题都被解决,并且本地构建成功,你可以再次尝试完整的 Maven 构建流程:
复制
mvn clean package -DskipTests
5.3[ERROR] Failed to execute goal on project flink-avro-confluent-registry: Could not resolve dependencies for project org.apache.flink:flink-avro-confluent-registry:jar:1.18-SNAPSHOT: Failed to collect dependencies at io.confluent :kafka-schema-registry-client:jar:7.2.2: Failed to read artifact descriptor for io.confluent:kafka-schema-registry-client:jar:7.2.2: The following artifacts could not be resolved: io.confluent:kafka-schema-registry-parent:pom:7.2.2 (present, but unavailable): Could not find artifact io.confluent:kafka-schema-registry-parent:pom:7.2.2 in nexus-aliyun
先去https://mvnrepository.com去搜索下载。
发现https://maven.ceon.pl/artifactory/repo/io/confluent/kafka-schema-registry-client/7.2.2/ 大 小有问题。爆了以下错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project flink-avro-confluent-registry: Compilation failure: Compilation failure:
[ERROR] error reading /Users/AllenBai/.m2/repository/io/confluent/kafka-schema-registry-client/3.3.1/kafka-schema-registry-client-7.2.2.jar; error in opening zip file
[ERROR] error reading /Users/AllenBai/.m2/repository/io/confluent/kafka-schema-registry-client/7.2.2/kafka-schema-registry-client-7.2.2.jar; error in opening zip file
wget http://packages.confluent.io/maven/io/confluent/kafka-schema-registry-client/7.2.2/kafka-schema-registry-client-7.2.2.jar
安装
mvn install:install-file -DgroupId='io.confluent' -DartifactId='kafka-schema-registry-client' -Dversion='7.2.2' -Dpackaging='jar' -Dfile='D:/Tools/jar/kafka-schema-registry-client-7.2.2.jar' '-DskipTests' '-Dmaven.javadoc.skip=true' '-Dmaven.compile.fork=true'
编译成功