kakfa源代码开发环境搭建过程中的错误处理

时间:2022-09-21 08:23:30

在window上搭建kafka的源代码开发环境,主要参考如下的blog:

http://www.bubuko.com/infodetail-695974.html    << Windows平台搭建Kafka源代码开发环境(Eclipse版本) >>

http://*.com/questions/25994163/could-not-resolve-all-dependencies-for-configuration-classpath

但是在国内的网络环境限制, 下载依赖的jar包出现了各种问题,本文将介绍如何修改kafka源代码中的构建文件,避免这些问题:

gradle下载:

https://services.gradle.org/distributions/gradle-2.9-all.zip

GRADLE_HOME

gradlew eclipse
gradle wrapper
http://dl.bintray.com/content/netflixoss/external-gradle-plugins/

D:\源码\kafka-0.8.2.1-src>gradle eclipse
To honour the JVM settings for this build a new JVM will be forked. Please consi
der using the daemon: http://gradle.org/docs/2.2.1/userguide/gradle_daemon.html.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'kafka-0.8.2.1-src'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve nl.javadude.gradle.plugins:license-gradle-plugin:0.10.0.
     Required by:
         org.apache.kafka:kafka-0.8.2.1-src:0.8.2.1
      > Could not GET 'https://repo1.maven.org/maven2/nl/javadude/gradle/plugins
/license-gradle-plugin/0.10.0/license-gradle-plugin-0.10.0.pom'.
         > peer not authenticated
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED

解决办法:
修改build.gradle
//buildscript {
//  repositories {
//    mavenCentral()
//  }
//  apply from: file('gradle/buildscript.gradle'), to: buildscript
//}

buildscript {
     repositories {
    jcenter {
//        url "http://jcenter.bintray.com/"
        maven { url 'http://repo1.maven.org/maven2' }
    }
    apply from: file('gradle/buildscript.gradle'), to: buildscript
  }
}

修改
//allprojects {
//  apply plugin: 'idea'
//  repositories {
//    mavenCentral()
//  }
//}

allprojects {
repositories {
    jcenter {
        url "http://jcenter.bintray.com/"
    }
  }
}
---------------------------
D:\源码\kafka-0.8.2.1-src>gradle wrapper
To honour the JVM settings for this build a new JVM will be forked. Please consi
der using the daemon: http://gradle.org/docs/2.2.1/userguide/gradle_daemon.html.
FAILURE: Build failed with an exception.
* Where:
Script 'D:\源码\kafka-0.8.2.1-src\gradle\license.gradle' line: 2
* What went wrong:
A problem occurred evaluating script.
> Failed to apply plugin [id 'license']
   > Plugin with id 'license' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
意思是  [id 'license'] 没有被发现,修改buildscript,添加apply from: file('gradle/buildscript.gradle'), to: buildscript
buildscript {
     repositories {
    jcenter {
//        url "http://jcenter.bintray.com/"
        maven { url 'http://repo1.maven.org/maven2' }
    }
    apply from: file('gradle/buildscript.gradle'), to: buildscript
  }
}
然后执行 grade  wrapper  #BUILD SUCCESSFUL
D:\源码\kafka-0.8.2.1-src>gradle wrapper
To honour the JVM settings for this build a new JVM will be forked. Please cons
der using the daemon: http://gradle.org/docs/2.2.1/userguide/gradle_daemon.html
Download http://repo1.maven.org/maven2/nl/javadude/gradle/plugins/license-gradl
-plugin/0.10.0/license-gradle-plugin-0.10.0.pom
Download http://repo1.maven.org/maven2/com/mycila/maven-license-plugin/maven-li
ense-plugin/1.10.b1/maven-license-plugin-1.10.b1.pom
Download http://repo1.maven.org/maven2/com/mycila/parent-pom/5/parent-pom-5.pom
Download http://repo1.maven.org/maven2/com/mycila/xmltool/xmltool/3.3/xmltool-3
3.pom
Download http://repo1.maven.org/maven2/nl/javadude/gradle/plugins/license-gradl
-plugin/0.10.0/license-gradle-plugin-0.10.0.jar
Download http://repo1.maven.org/maven2/com/mycila/maven-license-plugin/maven-li
ense-plugin/1.10.b1/maven-license-plugin-1.10.b1.jar
Download http://repo1.maven.org/maven2/com/mycila/xmltool/xmltool/3.3/xmltool-3
3.jar
Building project 'core' with Scala version 2.10.4
:wrapper
BUILD SUCCESSFUL
---------------------------------------------------

D:\源码\kafka-0.8.2.1-src>gradle eclipse

卡在 下载 scalatest_2.10/1.9.1/scalatest_2.10-1.9.1-sources.jar 的过程中,死活下载不了,

目前使用的是 http://jcenter.bintray.com/库,改成库 "http://repo1.maven.org/maven2/"  试一下,最后执行成功。

kakfa源代码开发环境搭建过程中的错误处理

vi build.gradle

修改如下配置:

allprojects {
repositories {
    jcenter {
//        url "http://jcenter.bintray.com/"
        url "http://repo1.maven.org/maven2/"
    }
  }
}
scalatest_2.10-1.9.1.jar of core build path is cross-compiled with an incompatible version of Scala (2.10.0). In case this report is mistaken, this check can be disabled in the compiler preference page.     core          Unknown     Scala Version Problem

--------------------------------------------------------------------

D:\源码\kafka-0.8.2.1-src>gradle idea

失败,

kakfa源代码开发环境搭建过程中的错误处理

解决办法,修改build.gradle

需改如下内容,

修改

//allprojects {
//  apply plugin: 'idea'
//  repositories {
//    mavenCentral()
//  }

//}

为,并加上apply plugin: 'idea' ,

allprojects {

repositories {

apply plugin: 'idea'

jcenter {
//        url "http://jcenter.bintray.com/"
        url "http://repo1.maven.org/maven2/"
    }
  }

}

------------------------------------------

maven { url 'http://repo1.maven.org/maven2' }
repositories {
    jcenter {
        url "http://jcenter.bintray.com/"
    }
}
repositories {
    maven  {
        url "http://repo1.maven.org/maven2"
    }

}