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><!–$NO-MVN-MAN-VER$–>-->
<!--<inherited>false</inherited>-->
<!--<executions>-->
<!--<execution>-->
<!--<phase>verify</phase>-->
<!--<goals>-->
<!--<goal>check</goal>-->
<!--</goals>-->
<!--</execution>-->
<!--</executions>-->
<!--<configuration>-->
<!--<excludeSubProjects>false</excludeSubProjects>-->
<!--<numUnapprovedLicenses>0</numUnapprovedLicenses>-->
<!--<licenses>-->
<!--<!– 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.-->
<!--–>-->
<!--<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>-->
<!--<!– Additional files like .gitignore etc.–>-->
<!--<exclude>**/.*/**</exclude>-->
<!--<exclude>**/*.prefs</exclude>-->
<!--<exclude>**/*.log</exclude>-->
<!--<!– External web libraries. –>-->
<!--<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>-->
<!--<!– the licenses that are re-bundled –>-->
<!--<exclude>**/packaged_licenses/LICENSE.*.txt</exclude>-->
<!--<exclude>**/licenses/LICENSE*</exclude>-->
<!--<exclude>**/licenses-binary/LICENSE*</exclude>-->
<!--<!– web dashboard config JSON files –>-->
<!--<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>-->
<!--<!– web dashboard non-binary assets –>-->
<!--<exclude>flink-runtime-web/web-dashboard/src/assets/**</exclude>-->
<!--<!– generated contents –>-->
<!--<exclude>flink-runtime-web/web-dashboard/web/**</exclude>-->
<!--<!– downloaded and generated web libraries. –>-->
<!--<exclude>flink-runtime-web/web-dashboard/node_modules/**</exclude>-->
<!--<exclude>flink-runtime-web/web-dashboard/node/**</exclude>-->
<!--<!– Test Data. –>-->
<!--<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>-->
<!--<!– snapshots –>-->
<!--<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>-->
<!--<!– netty test file, still Apache License 2.0 but with a different header –>-->
<!--<exclude>flink-runtime/src/test/java/org/apache/flink/runtime/io/network/buffer/AbstractByteBufTest.java</exclude>-->
<!--<!– Configuration Files. –>-->
<!--<exclude>**/flink-bin/conf/workers</exclude>-->
<!--<exclude>**/flink-bin/conf/masters</exclude>-->
<!--<!– Administrative files in the main trunk. –>-->
<!--<exclude>**/README.md</exclude>-->
<!--<exclude>.github/**</exclude>-->
<!--<!– Build files –>-->
<!--<exclude>**/*.iml</exclude>-->
<!--<exclude>flink-quickstart/**/testArtifact/goal.txt</exclude>-->
<!--<!– Generated content –>-->
<!--<exclude>out/**</exclude>-->
<!--<exclude>**/target/**</exclude>-->
<!--<exclude>docs/content/**</exclude>-->
<!--<exclude>**/scalastyle-output.xml</exclude>-->
<!--<exclude>build-target/**</exclude>-->
<!--<exclude>docs/_includes/generated/**</exclude>-->
<!--<!– Tools: watchdog –>-->
<!--<exclude>tools/artifacts/**</exclude>-->
<!--<exclude>tools/flink*/**</exclude>-->
<!--<!– Tools: japicmp output –>-->
<!--<exclude>tools/japicmp-output/**</exclude>-->
<!--<!– artifacts created during release process –>-->
<!--<exclude>tools/releasing/release/**</exclude>-->
<!--<!– manually installed version on travis –>-->
<!--<exclude>apache-maven-3.2.5/**</exclude>-->
<!--<!– PyCharm –>-->
<!--<exclude>**/.idea/**</exclude>-->
<!--<!– Generated code via Avro –>-->
<!--<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>-->
<!--<!– Files generated by jepsen tests –>-->
<!--<exclude>flink-jepsen/store/**</exclude>-->
<!--<exclude>flink-jepsen/docker/id_rsa*</exclude>-->
<!--<exclude>flink-jepsen/docker/nodes</exclude>-->
<!--<!– flink-python –>-->
<!--<exclude>flink-python/lib/**</exclude>-->
<!--<exclude>flink-python/dev/download/**</exclude>-->
<!--<exclude>flink-python/docs/_build/**</exclude>-->
<!--</excludes>-->
<!--</configuration>-->
<!--</plugin>-->