Flink之源码本地构建(一)

1、准备工作:

windows10 + java8 1.8.0_261 + maven3.1.1 + idea14

特别的,maven版本为官方推荐的,试了其他版本,未能成功构建。jdk8要用高版本的261。

2、从git clone源码,不再赘述 

https://github.com/apache/flink.git

3、右键源码根目录

4、时间大概需要半小时,耐心等待,可以去喝杯茶或者撸点代码...

5、wordcount小例子跑起来,开始源码之旅~

6、修改代码后,执行mvn clean install -DskipTests,等待...喝茶

 

FAQ:

1·、org.apache.flink.sql.parser.utils类中包导入import org.apache.flink.sql.parser.impl.ParseException失败问题。排查过程中,发现源码确实没有该包。最终切换maven版本后,重新generate Sources搞定。最终生成的源码,注意这个是maven插件生成的,文件夹的样式可以看出来。

2、Error:(550, 53) java: 未报告的异常错误X; 必须对其进行捕获或声明以便抛出 

一开始本地的jdk8是40小版本,静态代码编译不过,可是查了git发现代码也这样,那就不是代码原因,否则早改了。考虑是自身环境问题,升级jdk8 261版本后搞定。

3、license问题,注释根pom下的插件。

<!--<plugin>-->
				<!--<groupId>org.apache.rat</groupId>-->
				<!--<artifactId>apache-rat-plugin</artifactId>-->
				<!--<version>0.12</version>&lt;!&ndash;$NO-MVN-MAN-VER$&ndash;&gt;-->
				<!--<inherited>false</inherited>-->
				<!--<executions>-->
					<!--<execution>-->
						<!--<phase>verify</phase>-->
						<!--<goals>-->
							<!--<goal>check</goal>-->
						<!--</goals>-->
					<!--</execution>-->
				<!--</executions>-->
				<!--<configuration>-->
					<!--<excludeSubProjects>false</excludeSubProjects>-->
					<!--<numUnapprovedLicenses>0</numUnapprovedLicenses>-->
					<!--<licenses>-->
						<!--&lt;!&ndash; Enforce this license:-->
							<!--Licensed to the Apache Software Foundation (ASF) under one-->
							<!--or more contributor license agreements.  See the NOTICE file-->
							<!--distributed with this work for additional information-->
							<!--regarding copyright ownership.  The ASF licenses this file-->
							<!--to you under the Apache License, Version 2.0 (the-->
							<!--"License"); you may not use this file except in compliance-->
							<!--with the License.  You may obtain a copy of the License at-->
							  <!--http://www.apache.org/licenses/LICENSE-2.0-->
							<!--Unless required by applicable law or agreed to in writing,-->
							<!--software distributed under the License is distributed on an-->
							<!--"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY-->
							<!--KIND, either express or implied.  See the License for the-->
							<!--specific language governing permissions and limitations-->
							<!--under the License.-->
						<!--&ndash;&gt;-->
						<!--<license implementation="org.apache.rat.analysis.license.SimplePatternBasedLicense">-->
							<!--<licenseFamilyCategory>AL2 </licenseFamilyCategory>-->
							<!--<licenseFamilyName>Apache License 2.0</licenseFamilyName>-->
							<!--<notes />-->
							<!--<patterns>-->
								<!--<pattern>Licensed to the Apache Software Foundation (ASF) under one</pattern>-->
							<!--</patterns>-->
						<!--</license>-->
					<!--</licenses>-->
					<!--<licenseFamilies>-->
						<!--<licenseFamily implementation="org.apache.rat.license.SimpleLicenseFamily">-->
							<!--<familyName>Apache License 2.0</familyName>-->
						<!--</licenseFamily>-->
					<!--</licenseFamilies>-->
					<!--<excludes>-->
						<!--&lt;!&ndash; Additional files like .gitignore etc.&ndash;&gt;-->
						<!--<exclude>**/.*/**</exclude>-->
						<!--<exclude>**/*.prefs</exclude>-->
						<!--<exclude>**/*.log</exclude>-->
						<!--&lt;!&ndash; External web libraries. &ndash;&gt;-->
						<!--<exclude>docs/**/jquery*</exclude>-->
						<!--<exclude>docs/**/bootstrap*</exclude>-->
						<!--<exclude>docs/Gemfile.lock</exclude>-->
						<!--<exclude>docs/ruby2/Gemfile.lock</exclude>-->
						<!--<exclude>docs/img/*.svg</exclude>-->
						<!--<exclude>**/docs/page/font-awesome/**</exclude>-->
						<!--<exclude>**/resources/**/font-awesome/**</exclude>-->
						<!--<exclude>**/resources/**/jquery*</exclude>-->
						<!--<exclude>**/resources/**/bootstrap*</exclude>-->
						<!--<exclude>flink-clients/src/main/resources/web-docs/js/*d3.js</exclude>-->

						<!--&lt;!&ndash; the licenses that are re-bundled &ndash;&gt;-->
						<!--<exclude>**/packaged_licenses/LICENSE.*.txt</exclude>-->
						<!--<exclude>**/licenses/LICENSE*</exclude>-->
						<!--<exclude>**/licenses-binary/LICENSE*</exclude>-->

						<!--&lt;!&ndash; web dashboard config JSON files &ndash;&gt;-->
						<!--<exclude>flink-runtime-web/web-dashboard/package.json</exclude>-->
						<!--<exclude>flink-runtime-web/web-dashboard/package-lock.json</exclude>-->
						<!--<exclude>flink-runtime-web/web-dashboard/angular.json</exclude>-->
						<!--<exclude>flink-runtime-web/web-dashboard/proxy.conf.json</exclude>-->
						<!--<exclude>flink-runtime-web/web-dashboard/tsconfig.json</exclude>-->
						<!--<exclude>flink-runtime-web/web-dashboard/tslint.json</exclude>-->
						<!--<exclude>flink-runtime-web/web-dashboard/src/browserslist</exclude>-->
						<!--<exclude>flink-runtime-web/web-dashboard/src/tsconfig.app.json</exclude>-->
						<!--<exclude>flink-runtime-web/web-dashboard/src/tsconfig.spec.json</exclude>-->
						<!--<exclude>flink-runtime-web/web-dashboard/src/tslint.json</exclude>-->

						<!--&lt;!&ndash; web dashboard non-binary assets &ndash;&gt;-->
						<!--<exclude>flink-runtime-web/web-dashboard/src/assets/**</exclude>-->

						<!--&lt;!&ndash; generated contents &ndash;&gt;-->
						<!--<exclude>flink-runtime-web/web-dashboard/web/**</exclude>-->

						<!--&lt;!&ndash; downloaded and generated web libraries. &ndash;&gt;-->
						<!--<exclude>flink-runtime-web/web-dashboard/node_modules/**</exclude>-->
						<!--<exclude>flink-runtime-web/web-dashboard/node/**</exclude>-->

						<!--&lt;!&ndash; Test Data. &ndash;&gt;-->
						<!--<exclude>**/src/test/resources/*-data</exclude>-->
						<!--<exclude>flink-tests/src/test/resources/testdata/terainput.txt</exclude>-->
                        <!--<exclude>flink-formats/flink-avro/src/test/resources/flink_11-kryo_registrations</exclude>-->
						<!--<exclude>flink-runtime/src/test/resources/flink_11-kryo_registrations</exclude>-->
						<!--<exclude>flink-core/src/test/resources/kryo-serializer-config-snapshot-v1</exclude>-->
						<!--<exclude>flink-formats/flink-avro/src/test/resources/avro/*.avsc</exclude>-->
						<!--<exclude>out/test/flink-avro/avro/user.avsc</exclude>-->
						<!--<exclude>flink-table/flink-table-planner/src/test/scala/resources/*.out</exclude>-->
						<!--<exclude>flink-table/flink-table-planner-blink/src/test/resources/digest/*.out</exclude>-->
						<!--<exclude>flink-table/flink-table-planner-blink/src/test/resources/explain/*.out</exclude>-->
						<!--<exclude>flink-yarn/src/test/resources/krb5.keytab</exclude>-->
						<!--<exclude>flink-end-to-end-tests/test-scripts/test-data/**</exclude>-->
						<!--<exclude>flink-end-to-end-tests/test-scripts/docker-hadoop-secure-cluster/config/keystore.jks</exclude>-->
						<!--<exclude>flink-connectors/flink-connector-kafka/src/test/resources/**</exclude>-->
						<!--<exclude>flink-connectors/flink-connector-kafka-0.11/src/test/resources/**</exclude>-->
						<!--<exclude>flink-connectors/flink-connector-hive/src/test/resources/**</exclude>-->
						<!--<exclude>flink-end-to-end-tests/flink-tpcds-test/tpcds-tool/answer_set/*</exclude>-->
						<!--<exclude>flink-end-to-end-tests/flink-tpcds-test/tpcds-tool/query/*</exclude>-->

						<!--&lt;!&ndash; snapshots &ndash;&gt;-->
						<!--<exclude>**/src/test/resources/**/serializer-snapshot</exclude>-->
						<!--<exclude>**/src/test/resources/**/test-data</exclude>-->
						<!--<exclude>**/src/test/resources/*-snapshot</exclude>-->
						<!--<exclude>**/src/test/resources/*.snapshot</exclude>-->
						<!--<exclude>**/src/test/resources/*-savepoint</exclude>-->
						<!--<exclude>flink-core/src/test/resources/serialized-kryo-serializer-1.3</exclude>-->
						<!--<exclude>flink-core/src/test/resources/type-without-avro-serialized-using-kryo</exclude>-->
						<!--<exclude>flink-formats/flink-avro/src/test/resources/flink-1.4-serializer-java-serialized</exclude>-->

						<!--<exclude>flink-end-to-end-tests/flink-state-evolution-test/src/main/java/org/apache/flink/avro/generated/*</exclude>-->
						<!--<exclude>flink-end-to-end-tests/flink-state-evolution-test/savepoints/*</exclude>-->
						<!--<exclude>flink-formats/flink-avro/src/test/resources/testdata.avro</exclude>-->
						<!--<exclude>flink-formats/flink-avro/src/test/java/org/apache/flink/formats/avro/generated/*.java</exclude>-->
						<!--<exclude>flink-formats/flink-json/src/test/resources/*.txt</exclude>-->
						<!--<exclude>flink-formats/flink-parquet/src/test/java/org/apache/flink/formats/parquet/generated/*.java</exclude>-->
						<!--<exclude>flink-formats/flink-parquet/src/test/resources/avro/**</exclude>-->
						<!--&lt;!&ndash; netty test file, still Apache License 2.0 but with a different header &ndash;&gt;-->
						<!--<exclude>flink-runtime/src/test/java/org/apache/flink/runtime/io/network/buffer/AbstractByteBufTest.java</exclude>-->
						<!--&lt;!&ndash; Configuration Files. &ndash;&gt;-->
						<!--<exclude>**/flink-bin/conf/workers</exclude>-->
						<!--<exclude>**/flink-bin/conf/masters</exclude>-->
						<!--&lt;!&ndash; Administrative files in the main trunk. &ndash;&gt;-->
						<!--<exclude>**/README.md</exclude>-->
						<!--<exclude>.github/**</exclude>-->
						<!--&lt;!&ndash; Build files &ndash;&gt;-->
						<!--<exclude>**/*.iml</exclude>-->
						<!--<exclude>flink-quickstart/**/testArtifact/goal.txt</exclude>-->
						<!--&lt;!&ndash; Generated content &ndash;&gt;-->
						<!--<exclude>out/**</exclude>-->
						<!--<exclude>**/target/**</exclude>-->
						<!--<exclude>docs/content/**</exclude>-->
						<!--<exclude>**/scalastyle-output.xml</exclude>-->
						<!--<exclude>build-target/**</exclude>-->
						<!--<exclude>docs/_includes/generated/**</exclude>-->
						<!--&lt;!&ndash; Tools: watchdog &ndash;&gt;-->
						<!--<exclude>tools/artifacts/**</exclude>-->
						<!--<exclude>tools/flink*/**</exclude>-->
						<!--&lt;!&ndash; Tools: japicmp output &ndash;&gt;-->
						<!--<exclude>tools/japicmp-output/**</exclude>-->
						<!--&lt;!&ndash; artifacts created during release process &ndash;&gt;-->
						<!--<exclude>tools/releasing/release/**</exclude>-->
						<!--&lt;!&ndash; manually installed version on travis &ndash;&gt;-->
						<!--<exclude>apache-maven-3.2.5/**</exclude>-->
						<!--&lt;!&ndash; PyCharm &ndash;&gt;-->
						<!--<exclude>**/.idea/**</exclude>-->
						<!--&lt;!&ndash; Generated code via Avro &ndash;&gt;-->
						<!--<exclude>flink-end-to-end-tests/flink-confluent-schema-registry/src/main/java/example/avro/**</exclude>-->
						<!--<exclude>flink-end-to-end-tests/flink-datastream-allround-test/src/main/java/org/apache/flink/streaming/tests/avro/**</exclude>-->
						<!--&lt;!&ndash; Files generated by jepsen tests &ndash;&gt;-->
						<!--<exclude>flink-jepsen/store/**</exclude>-->
						<!--<exclude>flink-jepsen/docker/id_rsa*</exclude>-->
						<!--<exclude>flink-jepsen/docker/nodes</exclude>-->

						<!--&lt;!&ndash; flink-python &ndash;&gt;-->
						<!--<exclude>flink-python/lib/**</exclude>-->
						<!--<exclude>flink-python/dev/download/**</exclude>-->
						<!--<exclude>flink-python/docs/_build/**</exclude>-->
					<!--</excludes>-->
				<!--</configuration>-->
			<!--</plugin>-->

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值