一、编译前准备
1、拉取代码
仓库地址是:https://github.com/prestodb/presto.git
2、安装cygwin
cygwin官网
在官网下载cygwin,安装好后在windows环境变量的Path加上cygwin的bin路径。
ps:没装cygwin可能会报有些命令找不到的错,例如:Cannot run program “chmod”: CreateProcess error=2
3、重新编译presto-maven-plugin
Presto使用presto-maven-plugin编译。在Window下编译失败原因是编译过程中类找不到,而且文件路径错了。这里Presto使用的presto-maven-plugin的版本为0.5-SNAPSHOT
git clone https://github.com/prestodb/presto-maven-plugin.git
克隆好了后修改该仓库的ServiceDescriptorGenerator.java
String className = classPath.substring(0, classPath.length() - 6).replace('/', '.');
修改后:
String className = classPath.substring(0, classPath.length() - 6).replace(File.separatorChar, '.');
然后在项目下执行:
mvn clean install -DskipTests
将产生的presto-maven-plugin-0.5-SNAPSHOT.jar 放入本地maven仓库的***com\facebook\presto\presto-maven-plugin\0.5-SNAPSHOT*** 目录
没有这个目录可以使用
mvn install:install-file -DgroupId=xx.xx -DartifactId=xx -Dversion=xx -Dpackaging=jar -Dfile=xx
命令行导入
4、注释掉presto-root下面的pom.xml内容
4.1、在presto-root模块的pom.xml中properties部分添加以下内容:
<air.check.skip-extended>true</air.check.skip-extended>
并且注释掉
<air.checkstyle.config-file>src/checkstyle/presto-checks.xml</air.checkstyle.config-file>
因为Presto会对代码规范进行严格的检查,maven-checkstyle-plugin检查失败就会报错,不注释上面的编译时会报错:
Error: java: RegexpMultiline: Line contains carriage return
4.2、注释掉presto-docs模块
<!--module>presto-docs</module>-->
原因:Presto Github上说明了它支持Linux / Mac 编译
4.3、注意jdk版本
<air.java.version>1.8.0-151</air.java.version>
presto这里也比较严格,笔者jdk版本是1.8.0-131,第一次没改的时候因为版低于151导致编译失败,可以下载高于151的版本也可以像笔者把这个改成
<air.java.version>1.8.0-131</air.java.version>
二、编译源码
1、在拉下来的仓库目录执行
mvn clean install -DskipTests
等待20多分钟左右
编译完成后在presto-server模块可以找到:
presto-server-0.257-SNAPSHOT.tar.gz
参考:
[1]: https://blog.csdn.net/hll19950830/article/details/108715511
[2]: https://www.freesion.com/article/50941383225/