亲宝软件园·资讯

展开

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

偶尔发呆 人气:0
想了解windows下使用 intellij idea 编译 kafka 源码环境的相关内容吗,有时发呆在本文为您仔细讲解 idea 编译 kafka 源码的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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 依赖配置好。

加载全部内容

相关教程
猜你喜欢
用户评论