github上下载kafka源码https://github.com/apache/kafka/tree/0.10.2
jdk:1.8
scala:2.11.8
gradle 5.0
gradle安装很简单,类似配置jdk
配置好验证下(之前装的5.0)
修改kafka项目中的仓库地址
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven{ url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
编译遇到问题
1.gradle 5.0 与旧版本不兼容问题
You can't map a property that does not exist: propertyName=testClassesDir
遇到这个问题修改好了。。。
解决方案:
升级依赖包参照 KAFKA-7706 的 patch:
https://issues.apache.org/jira/secure/attachment/12950666/0001-fix-bug-build-fails-wiht-gradle-5.0.patch
classpath 'org.scoverage:gradle-scoverage:2.5.0'
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1'
2版本问题
Caused by: java.lang.AbstractMethodError
at org.gradle.api.internal.artifacts.ivyservice.resolutionstrategy.DefaultCachePolicy
gradle5.x版本问题很多,issue如下,决定更换版本
Gradle-issue:https://github.com/gradle/gradle/issues/8088
最终直接卸载了装了5.0版本 装了4.10
完美解决问题。