Browse Source

KAFKA-12415 Prepare for Gradle 7.0 and restrict transitive scope for non api dependencies (#10203)

Gradle 7.0 is required for Java 16 compatibility and it removes a number of
deprecated APIs. Fix most issues preventing the upgrade to Gradle 7.0.
The remaining ones are more complicated and should be handled
in a separate PR. Details of the changes:

* Release tarball no longer includes includes test, sources, javadoc and test sources jars (these
are still published to the Maven Central repository).
* Replace `compile` with `api` or `implementation` - note that `implementation`
dependencies appear with `runtime` scope in the pom file so this is a (positive)
change in behavior
* Add missing dependencies that were uncovered by the usage of `implementation`
* Replace `testCompile` with `testImplementation`
* Replace `runtime` with `runtimeOnly` and `testRuntime` with `testRuntimeOnly`
* Replace `configurations.runtime` with `configurations.runtimeClasspath`
* Replace `configurations.testRuntime` with `configurations.testRuntimeClasspath` (except for
the usage in the `streams` project as that causes a cyclic dependency error)
* Use `java-library` plugin instead of `java`
* Use `maven-publish` plugin instead of deprecated `maven` plugin - this changes the
commands used to publish and to install locally, but task aliases for `install` and
`uploadArchives` were added for backwards compatibility
* Removed `-x signArchives` line from the readme since it was wrong (it was a
no-op before and it fails now, however)
* Replaces `artifacts` block with an approach that works with the `maven-publish` plugin
* Don't publish `jmh-benchmark` module - the shadow jar is pretty large and not
particularly useful (before this PR, we would publish the non shadow jars)
* Replace `version` with `archiveVersion`, `baseName` with `archiveBaseName` and
`classifier` with `archiveClassifier`
* Update Gradle and plugins to the latest stable version (7.0 is not stable yet)
* Use `plugin` DSL to configure plugins
* Updated notable changes for 3.0

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Randall Hauch <rhauch@gmail.com>
pull/10264/head
Ismael Juma 4 years ago committed by GitHub
parent
commit
7a3ebbebbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      Jenkinsfile
  2. 16
      README.md
  3. 836
      build.gradle
  4. 8
      docs/upgrade.html
  5. 9
      gradle/dependencies.gradle
  6. 2
      gradle/wrapper/gradle-wrapper.properties
  7. 2
      gradlew
  8. 2
      jmh-benchmarks/README.md
  9. 2
      jmh-benchmarks/jmh.sh
  10. 2
      release.py

4
Jenkinsfile vendored

@ -46,8 +46,8 @@ def doStreamsArchetype() { @@ -46,8 +46,8 @@ def doStreamsArchetype() {
echo 'Verify that Kafka Streams archetype compiles'
sh '''
./gradlew streams:install clients:install connect:json:install connect:api:install \
|| { echo 'Could not install kafka-streams.jar (and dependencies) locally`'; exit 1; }
./gradlew streams:publishToMavenLocal clients:publishToMavenLocal connect:json:publishToMavenLocal connect:api:publishToMavenLocal \
|| { echo 'Could not publish kafka-streams.jar (and dependencies) locally to Maven'; exit 1; }
'''
VERSION = sh(script: 'grep "^version=" gradle.properties | cut -d= -f 2', returnStdout: true).trim()

16
README.md

@ -69,10 +69,6 @@ Generate coverage for a single module, i.e.: @@ -69,10 +69,6 @@ Generate coverage for a single module, i.e.:
### 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/`.
### Building auto generated messages ###
@ -125,6 +121,12 @@ build directory (`${project_dir}/bin`) clashes with Kafka's scripts directory an @@ -125,6 +121,12 @@ build directory (`${project_dir}/bin`) clashes with Kafka's scripts directory an
to avoid known issues with this configuration.
### Publishing the jar for all version of Scala and for all projects to maven ###
The recommended command is:
./gradlewAll publish
For backwards compatibility, the following also works:
./gradlewAll uploadArchives
Please note for this to work you should create/update `${GRADLE_USER_HOME}/gradle.properties` (typically, `~/.gradle/gradle.properties`) and assign the following variables
@ -167,6 +169,12 @@ Please note for this to work you should create/update user maven settings (typic @@ -167,6 +169,12 @@ Please note for this to work you should create/update user maven settings (typic
### Installing the jars to the local Maven repository ###
The recommended command is:
./gradlewAll publishToMavenLocal
For backwards compatibility, the following also works:
./gradlewAll install
### Building the test jar ###

836
build.gradle

File diff suppressed because it is too large Load Diff

8
docs/upgrade.html

@ -19,6 +19,14 @@ @@ -19,6 +19,14 @@
<script id="upgrade-template" type="text/x-handlebars-template">
<h5><a id="upgrade_300_notable" href="#upgrade_300_notable">Notable changes in 3.0.0</a></h5>
<ul>
<li>The release tarball no longer includes test, sources, javadoc and test sources jars. These are still published to the Maven Central repository. </li>
<li>A number of implementation dependency jars are <a href="https://github.com/apache/kafka/pull/10203">now available in the runtime classpath
instead of compile and runtime classpaths</a>. Compilation errors after the upgrade can be fixed by adding the missing dependency jar(s) explicitly
or updating the application not to use internal classes.</li>
</ul>
<h5><a id="upgrade_280_notable" href="#upgrade_280_notable">Notable changes in 2.8.0</a></h5>
<ul>
<li>

9
gradle/dependencies.gradle

@ -61,8 +61,7 @@ versions += [ @@ -61,8 +61,7 @@ versions += [
bcpkix: "1.66",
checkstyle: "8.20",
commonsCli: "1.4",
gradle: "6.8.1",
gradleVersionsPlugin: "0.36.0",
gradle: "6.8.3",
grgit: "4.1.0",
httpclient: "4.5.13",
easymock: "4.2",
@ -101,7 +100,6 @@ versions += [ @@ -101,7 +100,6 @@ versions += [
metrics: "2.2.0",
mockito: "3.6.0",
netty: "4.1.59.Final",
owaspDepCheckPlugin: "6.0.3",
powermock: "2.0.9",
reflections: "0.9.12",
rocksDB: "5.18.4",
@ -110,14 +108,9 @@ versions += [ @@ -110,14 +108,9 @@ versions += [
scalaJava8Compat : "0.9.1",
scalatest: "3.0.8",
scoverage: "1.4.1",
scoveragePlugin: "5.0.0",
shadowPlugin: "6.1.0",
slf4j: "1.7.30",
snappy: "1.1.8.1",
spotbugs: "4.1.4",
spotbugsPlugin: "4.6.0",
spotlessPlugin: "5.8.2",
testRetryPlugin: "1.2.0",
zinc: "1.3.5",
zookeeper: "3.5.9",
zstd: "1.4.8-4"

2
gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
gradlew vendored

@ -84,7 +84,7 @@ esac @@ -84,7 +84,7 @@ esac
# Loop in case we encounter an error.
for attempt in 1 2 3; do
if [ ! -e "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" ]; then
if ! curl -s -S --retry 3 -L -o "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" "https://raw.githubusercontent.com/gradle/gradle/v6.8.1/gradle/wrapper/gradle-wrapper.jar"; then
if ! curl -s -S --retry 3 -L -o "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" "https://raw.githubusercontent.com/gradle/gradle/v6.8.3/gradle/wrapper/gradle-wrapper.jar"; then
rm -f "$APP_HOME/gradle/wrapper/gradle-wrapper.jar"
# Pause for a bit before looping in case the server throttled us.
sleep 5

2
jmh-benchmarks/README.md

@ -62,7 +62,7 @@ per second which can increase when you have make your code faster. @@ -62,7 +62,7 @@ per second which can increase when you have make your code faster.
The JMH benchmarks can be run outside of gradle as you would with any executable jar file:
java -jar <kafka-repo-dir>/jmh-benchmarks/build/libs/kafka-jmh-benchmarks-all.jar -f2 LRUCacheBenchmark
java -jar <kafka-repo-dir>/jmh-benchmarks/build/libs/kafka-jmh-benchmarks-*.jar -f2 LRUCacheBenchmark
### Writing benchmarks

2
jmh-benchmarks/jmh.sh

@ -37,6 +37,6 @@ echo "gradle build done" @@ -37,6 +37,6 @@ echo "gradle build done"
echo "running JMH with args: $@"
java -jar ${libDir}/kafka-jmh-benchmarks-all.jar "$@"
java -jar ${libDir}/kafka-jmh-benchmarks-*.jar "$@"
echo "JMH benchmarks done"

2
release.py

@ -631,7 +631,7 @@ with open(os.path.expanduser("~/.gradle/gradle.properties")) as f: @@ -631,7 +631,7 @@ with open(os.path.expanduser("~/.gradle/gradle.properties")) as f:
contents = f.read()
if not user_ok("Going to build and upload mvn artifacts based on these settings:\n" + contents + '\nOK (y/n)?: '):
fail("Retry again later")
cmd("Building and uploading archives", "./gradlewAll uploadArchives", cwd=kafka_dir, env=jdk8_env, shell=True)
cmd("Building and uploading archives", "./gradlewAll publish", cwd=kafka_dir, env=jdk8_env, shell=True)
cmd("Building and uploading archives", "mvn deploy -Pgpg-signing", cwd=streams_quickstart_dir, env=jdk8_env, shell=True)
release_notification_props = { 'release_version': release_version,

Loading…
Cancel
Save