从Scala官方网站下载,
https://www.scala-lang.org/download/all.html
windows版本的安装包是scala-XX.XX.XX.msi。 ·使用下载下来的安装包安装Scala
也可以从疯狂创客圈的 网盘下载
安装 scala点击安装即可
配置scala环境变量SCALA_HOME:scala安装目录
Path:%SCALA_HOME%\bin;
在gitbash中输入scala验证scala是否成功安装 MINGW64 /e/ref/kafka $ scala Welcome to Scala 2.11.12 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_91). Type in expressions for evaluation. Or try :help. scala> 下载源码:仓库地址:
https://codeload.github.com/apache/kafka/zip/trunk码云的地址:
https://gitee.com/apache/kafka.git码云下载更快。
[core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = https://gitee.com/apache/kafka.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "trunk"] remote = origin merge = refs/heads/trunk [branch "1.0"] remote = origin merge = refs/heads/1.0 [branch "0.10.1"] remote = origin merge = refs/heads/0.10.1 [branch "1.1"] remote = origin merge = refs/heads/1.1 [http] sslVerify = false 修改镜像仓库到阿里云修改里build.gradle的镜像仓库到阿里云
build.gradle 中 设置 aliyun 代理 build.gradle
build.gradle 中 dependencies 修改
dependencies { // For Apache Rat plugin to ignore non-Git files classpath "org.ajoberstar:grgit:1.9.3" classpath \'com.github.ben-manes:gradle-versions-plugin:0.15.0\' classpath \'org.scoverage:gradle-scoverage:2.5.0\' // 将2.1.0修改为2.5.0 classpath \'com.github.jengelman.gradle.plugins:shadow:2.0.1\' }修改gradle/buildscript.gradle 里的镜像仓库到阿里云
repositories { repositories { // For license plugin. maven { //url \'http://dl.bintray.com/content/netflixoss/external-gradle-plugins/\' //原有注释 //新增 url \'http://maven.aliyun.com/nexus/content/groups/public/\' } } } 源码编译 下载 Gradle 的 Wrapper 程序套件代码下载完成之后,会自动创建一个名为 kafka 的子目录,此时需要进入到该目录下,执行下面的这条命令,主要目的是下载 Gradle 的 Wrapper 程序套件。
$ gradle Starting a Gradle Daemon (subsequent builds will be faster) > Configure project : Building project \'core\' with Scala version 2.12.9 Building project \'streams-scala\' with Scala version 2.12.9 Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use \'--warning-mode all\' to show the individual deprecation warnings. See https://docs.gradle.org/5.3/userguide/command_line_interface.html#sec:command_line_warningGradle 的 Wrapper 程序套件 叫做 gradlew, 是一个shell脚本,需要 在shell 执行工具中打开。
可以在 gitbash 中打开。
通过gitbash 将 Kafka 源码编译打包成 Jar 文件通过gitbash ,在windows上使用shell脚本:
现在,你可以运行下列命令,将 Kafka 源码编译打包成 Jar 文件:
gradle在执行build的时候想跳过test task,那么可以使用-x命令
-x参数用来排除不需要执行的任务
./gradlew jarall ./gradlew clean releaseTarGz -x test