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 co