Presto在Windows环境下编译错误

最近在尝试重写presto-kafka,对接kafka1.0,在Windows环境下编译打包presto-kafka时候报错

1
2
3
[ERROR] Failed to execute goal io.takari.maven.plugins:presto-maven-plugin:0.1.12:generate-service-descriptor (default-generate-service-descriptor) on project presto-jmx: Execution default-generate-service-descriptor of goal io
.takari.maven.plugins:presto-maven-plugin:0.1.12:generate-service-descriptor failed: A required class was missing while executing io.takari.maven.plugins:presto-maven-plugin:0.1.12:generate-service-descriptor: com\facebook\pres
to\kafka\KafkaColumnHandle (wrong name: com/facebook/presto/kafka/KafkaColumnHandle)

Presto Github上说的很明确,Presto只支持在Linux环境下编译

官方在Issues里也确认了这一点,但从报错信息上来看,似乎是类名不对,把presto-maven-plugin的代码拉下来看了一下

1
2
3
line 122

String className = classPath.substring(0, classPath.length() - 6).replace('/', '.');

类名是通过把类路径的文件分隔符替换成点号来生成,但问题是Windows的分隔符是反斜杠\,而不是/,所以在Windows环境下这个替换没起作用,造成ClassNotFoundException,把'/'替换成File.separatorChar就好了

另外还碰到的一个问题是

1
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (checkstyle) on project presto-kafka: You have 43401 Checkstyle violations. -> [Help 1]

原因是重写之后的代码不符合规范,maven-checkstyle-plugin检查失败,如果不打算根据presto的规范改的话,一个粗暴的解决办法是在pom.xml添加properties:<air.check.skip-extended>true</air.check.skip-extended>,直接忽略检查

还有一个类似的问题是jar包冲突的检查,可以通过<air.check.fail-dependency>false</air.check.fail-dependency>忽略