kafka gradlew编译环境搭建
kafka源码编译java -version #必须先安装jdkbrew install gradle安装的为gradle-5.0-bin.zip#MAC系统需要安装gradle安装完成之后没有gradlew 命令https://downloads.gradle.org/distributions/gradle-5.0-all.zip查找gradlew可执行文件.//gra...
·
kafka源码编译
java -version #必须先安装jdk
brew install gradle安装的为gradle-5.0-bin.zip #MAC系统需要安装gradle
安装完成之后没有gradlew 命令
https://downloads.gradle.org/distributions/gradle-5.0-all.zip
查找gradlew可执行文件
.//gradle-5.0/samples/userguide/wrapper/sha256-verification/gradlew
gradlew拷贝到kafka目录下
然后编译测试
zhangjinyudeMacBook-Pro:Downloads zhangjinyu$ cd kafka
Build a jar and run it
zhangjinyudeMacBook-Pro:kafka zhangjinyu$ ./gradlew jar
Build source jar
zhangjinyudeMacBook-Pro:kafka zhangjinyu$ ./gradlew srcJar
Build aggregated javadoc
zhangjinyudeMacBook-Pro:kafka zhangjinyu$ ./gradlew aggregatedJavadoc
Build javadoc and scaladoc
./gradlew javadoc
./gradlew javadocJar # builds a javadoc jar for each module
./gradlew scaladoc
./gradlew scaladocJar # builds a scaladoc jar for each module
./gradlew docsJar # builds both (if applicable) javadoc and scaladoc jars for each module
Run unit/integration tests
./gradlew test # runs both unit and integration tests
./gradlew unitTest
./gradlew integrationTest
Force re-running tests without code change
./gradlew cleanTest test
./gradlew cleanTest unitTest
./gradlew cleanTest integrationTest
Running a particular unit/integration test
./gradlew clients:test --tests RequestResponseTest
Running a particular test method within a unit/integration test
./gradlew core:test --tests kafka.api.ProducerFailureHandlingTest.testCannotSendToInternalTopic
./gradlew clients:test --tests org.apache.kafka.clients.MetadataTest.testMetadataUpdateWaitTime
Running a particular unit/integration test with log4j output
Change the log4j setting in either
clients/src/test/resources/log4j.properties or core/src/test/resources/log4j.properties
./gradlew clients:test --tests RequestResponseTest
Generating test coverage reports
./gradlew reportCoverage
Generate coverage for a single module, i.e.:
./gradlew clients:reportCoverage
Building a binary release gzipped tar ball
./gradlew clean releaseTarGz
The above command will fail if you haven't set up the signing key. To bypass signing the artifact, you can run:
./gradlew clean releaseTarGz -x signArchives
The release file can be found inside ./core/build/distributions/.
Cleaning the build
./gradlew clean
Running a task with a particular version of Scala (either 2.11.x or 2.12.x)
./gradlew -PscalaVersion=2.12 jar
./gradlew -PscalaVersion=2.12 test
./gradlew -PscalaVersion=2.12 releaseTarGz
Running a task with all scala versions:Append All to the task name:
./gradlew testAll
./gradlew jarAll
./gradlew releaseTarGzAll
Running a task for a specific project
This is for core, examples and clients
./gradlew core:jar
./gradlew core:test
Listing all gradle tasks
./gradlew tasks
Building IDE project
Note that this is not strictly necessary (IntelliJ IDEA has good built-in support for Gradle projects, for example).
./gradlew eclipse
./gradlew idea
The eclipse task has been configured to use ${project_dir}/build_eclipseas Eclipse's build directory. Eclipse's default build directory (${project_dir}/bin) clashes with Kafka's scripts directory and we don't use Gradle's build directory to avoid known issues with this configuration.
Publishing the jar for all version of Scala and for all projects to maven
./gradlew uploadArchivesAll
Publishing the streams quickstart archetype artifact to maven
For the Streams archetype project, one cannot use gradle to upload to maven; instead the mvn deploy command needs to be called at the quickstart folder:
cd streams/quickstart
mvn deploy
Please note for this to work you should create/update user maven settings (typically, ${USER_HOME}/.m2/settings.xml) to assign the following variables
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<servers>
...
<server>
<id>apache.snapshots.https</id>
<username>${maven_username}</username>
<password>${maven_password}</password>
</server>
<server>
<id>apache.releases.https</id>
<username>${maven_username}</username>
<password>${maven_password}</password>
</server>
...
</servers>
...
Installing the jars to the local Maven repository
./gradlew installAll
Building the test jar
./gradlew testJar
Determining how transitive dependencies are added
./gradlew core:dependencies --configuration runtime
Determining if any dependencies could be updated
./gradlew dependencyUpdates
Running code quality checks
There are two code quality analysis tools that we regularly run, spotbugs and checkstyle.
Checkstyle
Checkstyle enforces a consistent coding style in Kafka. You can run checkstyle using:
./gradlew checkstyleMain checkstyleTest
更多推荐
已为社区贡献2条内容
所有评论(0)