windows下使用 intellij idea 编译 kafka 源码环境

1. 从 GitHub 网站,git clone kafka 源码

2. 下载安装好 gradle,scala

  2.1 从 dependencies.gradle 文件中找到 gradle 的版本,然后下载指定版本,并配置好 GRADLE_HOME 环境变量

3. 进入 kafka 项目目录,依次执行 gradle wrapper,gradle idea,gradle build --exclude-task test

4. 将工程导入到 idea

  4.1 启动主类 kafka.Kafka

  4.2 program arguments:config/server.properties

  4.3 把 config 目录下的 log4j.properties 拷贝到 core/src/main/resources 目录

  4.4 File -> Project Structure -> Modules

5. 启动程序

然而,大部分情况下,日志不会打印出来,配置一下 core 模块的 log4j 依赖

找到 build.gradle 文件中的 project(':core'),修改对应的 log4j 依赖,然后重新执行  gradle idea,重新导入 idea 中

project(':core') {

println "Building project 'core' with Scala version ${versions.scala}"

apply plugin: 'scala'

// scaladoc generation is configured at the sub-module level with an artifacts

// block (cf. see streams-scala). If scaladoc generation is invoked explicitly

// for the `core` module, this ensures the generated jar doesn't include scaladoc

// files since the `core` module doesn't include public APIs.

scaladoc {

enabled = false

}

if (userEnableTestCoverage)

apply plugin: "org.scoverage"

archivesBaseName = "kafka_${versions.baseScala}"

dependencies {

compile project(':clients')

compile project(':metadata')

compile project(':raft')

compile libs.argparse4j

compile libs.jacksonDatabind

compile libs.jacksonModuleScala

compile libs.jacksonDataformatCsv

compile libs.jacksonJDK8Datatypes

compile libs.joptSimple

compile libs.metrics

compile libs.scalaCollectionCompat

compile libs.scalaJava8Compat

compile libs.scalaLibrary

// only needed transitively, but set it explicitly to ensure it has the same version as scala-library

compile libs.scalaReflect

compile libs.scalaLogging

compile libs.slf4jApi

compile libs.slf4jlog4j

compile libs.log4j

compile(libs.zookeeper) {

// exclude module: 'slf4j-log4j12'

// exclude module: 'log4j'

}

// ZooKeeperMain depends on commons-cli but declares the dependency as `provided`

compile libs.commonsCli

compileOnly libs.log4j

testCompile project(':clients').sourceSets.test.output

testCompile libs.bcpkix

testCompile libs.mockitoCore

testCompile libs.easymock

testCompile(libs.apacheda) {

exclude group: 'xml-apis', module: 'xml-apis'

// `mina-core` is a transitive dependency for `apacheds` and `apacheda`.

// It is safer to use from `apacheds` since that is the implementation.

exclude module: 'mina-core'

}

testCompile libs.apachedsCoreApi

testCompile libs.apachedsInterceptorKerberos

testCompile libs.apachedsProtocolShared

testCompile libs.apachedsProtocolKerberos

testCompile libs.apachedsProtocolLdap

testCompile libs.apachedsLdifPartition

testCompile libs.apachedsMavibotPartition

testCompile libs.apachedsJdbmPartition

testCompile libs.junitJupiter

testCompile libs.slf4jlog4j

testCompile(libs.jfreechart) {

exclude group: 'junit', module: 'junit'

}

}

目标就是把下图的 log4j 依赖配置好。

到此这篇关于windows下使用 intellij idea 编译 kafka 源码环境的文章就介绍到这了,更多相关 idea 编译 kafka 源码内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!

以上是 windows下使用 intellij idea 编译 kafka 源码环境 的全部内容, 来源链接: utcz.com/p/249891.html

回到顶部