下载Kafka源码
官方下载源码地址:http://archive.apache.org/dist/kafka/1.0.2/kafka-1.0.2-src.tgz
安装配置Gradle
官方gradle-4.8.1下载地址:https://services.gradle.org/distributions/gradle-4.8.1-bin.zip
解压gradle-4.8.1-bin.zip到⼀个⽬录,如下图:
配置环境变量,其中GRADLE_HOME指向gradle解压到的根⽬录,GRADLE_USER_HOME指向gradle的本地仓库位置。
进⼊GRADLE_USER_HOME⽬录,添加init.gradle,配置gradle的源
init.gradle内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| allprojects { repositories { maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' } maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' } maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter'}
all { ArtifactRepository repo -> if (repo instanceof MavenArtifactRepository) { def url = repo.url.toString()
if (url.startsWith('https://repo.maven.apache.org/maven2/') || url.startsWith('https://repo.maven.org/maven2') || url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) { //project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL." remove repo } } } }
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/repository/public/'} maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' } maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' } maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter'} all { ArtifactRepository repo -> if (repo instanceof MavenArtifactRepository) { def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) { //project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL." remove repo } } } } } }
|
验证安装是否成功,打开cmd,运⾏如下:
设置成功。
安装和配置Scala
双击安装scala-2.12.12.msi。
配置环境变量SCALA_HOME,添加gradle的bin⽬录到PATH中。
打开cmd,输⼊ scala 验证:
输⼊:quit退出Scala的交互式环境。
Idea配置
Idea安装Scala插件
源码操作
解压源码到一个目录,如下图:
进⼊解压目录下的kafka-1.0.2-src,打开CMD,执⾏:gradle
结束后,执⾏gradle idea(注意不要使⽤⽣成的gradlew.bat执⾏操作)
结束后,idea导⼊源码
选择加载Gradle