Skip to content

Commit c6bbbbe

Browse files
authored
KAFKA-19174 Gradle version upgrade 8 -->> 9 (#19513)
List of changes: - prerequisite Jira ticket: - [KAFKA-19591](https://issues.apache.org/jira/browse/KAFKA-19591) - mandatory version upgrades: - Gradle version: 8.14.3 -->> 9.1.0 - Gradle Shadow plugin: 8.3.6 -->> 8.3.9 - Gradle dependencycheck plugin: 8.2.1 -->> 12.1.3 - Gradle spotbugs plugin: 6.2.3 -->> 6.2.5 - Gradle spotless plugin: 6.25.0 -->> 7.2.1 - build logic will be refactored to accommodate Gradle 9 breaking changes - (optional): a dozen of Gradle plugins versions will also be upgraded - other JIRA tickets that had to be solved all along: - [KAFKA-16801](https://issues.apache.org/jira/browse/KAFKA-16801) - [KAFKA-19654](https://issues.apache.org/jira/browse/KAFKA-19654) **Related links:** - https://gradle.org/whats-new/gradle-9 - https://github.com/gradle/gradle/releases/tag/v9.0.0 - https://docs.gradle.org/9.0.0/release-notes.html - https://docs.gradle.org/9.0.0/userguide/upgrading_major_version_9.html - https://docs.gradle.org/9.1.0/release-notes.html Notes: - new Gradle version brings up some breaking changes, as always 😃 - Kafka build with Gradle 9 has same issues as other projects: - redhat-developer/vscode-java#4018 - gradle/gradle#32597 Reviewers: Chia-Ping Tsai <[email protected]>
1 parent f5a87b3 commit c6bbbbe

File tree

6 files changed

+46
-38
lines changed

6 files changed

+46
-38
lines changed

.github/actions/setup-gradle/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ runs:
4242
distribution: temurin
4343
java-version: ${{ inputs.java-version }}
4444
- name: Setup Gradle
45-
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0
45+
uses: gradle/actions/setup-gradle@748248ddd2a24f49513d8f472f81c3a07d4d50e1 # v4.4.4
4646
env:
4747
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
4848
with:

build.gradle

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,21 @@ buildscript {
2929
}
3030

3131
plugins {
32-
id 'com.github.ben-manes.versions' version '0.48.0'
32+
id 'com.github.ben-manes.versions' version '0.52.0'
3333
id 'idea'
3434
id 'jacoco'
3535
id 'java-library'
36-
id 'org.owasp.dependencycheck' version '8.2.1'
36+
id 'org.owasp.dependencycheck' version '12.1.3'
3737
id 'org.nosphere.apache.rat' version "0.8.1"
3838
id "io.swagger.core.v3.swagger-gradle-plugin" version "${swaggerVersion}"
3939

40-
id "com.github.spotbugs" version '6.2.3' apply false
40+
id "com.github.spotbugs" version '6.2.5' apply false
4141
id 'org.scoverage' version '8.0.3' apply false
42-
id 'com.gradleup.shadow' version '8.3.6' apply false
43-
id 'com.diffplug.spotless' version "6.25.0"
42+
id 'com.gradleup.shadow' version '8.3.9' apply false
43+
id 'com.diffplug.spotless' version "7.2.1"
4444
}
4545

4646
ext {
47-
gradleVersion = versions.gradle
4847
minClientJavaVersion = 11
4948
minNonClientJavaVersion = 17
5049
modulesNeedingJava11 = [":clients", ":generator", ":streams", ":streams:test-utils", ":streams:examples", ":streams-scala", ":test-common:test-common-util"]
@@ -297,7 +296,7 @@ if (repo != null) {
297296
} else {
298297
rat.enabled = false
299298
}
300-
println("Starting build with version $version (commit id ${commitId == null ? "null" : commitId.take(8)}) using Gradle $gradleVersion, Java ${JavaVersion.current()} and Scala ${versions.scala}")
299+
println("Starting build with version $version (commit id ${commitId == null ? "null" : commitId.take(8)}) using Gradle $versions.gradle, Java ${JavaVersion.current()} and Scala ${versions.scala}")
301300
println("Build properties: ignoreFailures=$userIgnoreFailures, maxParallelForks=$maxTestForks, maxScalacThreads=$maxScalacThreads, maxTestRetries=$userMaxTestRetries")
302301

303302
subprojects {
@@ -328,6 +327,16 @@ subprojects {
328327
tasks.register('uploadArchives').configure { dependsOn(publish) }
329328
}
330329

330+
tasks.withType(AbstractArchiveTask).configureEach {
331+
reproducibleFileOrder = false
332+
preserveFileTimestamps = true
333+
useFileSystemPermissions()
334+
}
335+
336+
tasks.withType(AbstractTestTask).configureEach {
337+
failOnNoDiscoveredTests = false
338+
}
339+
331340
// apply the eclipse plugin only to subprojects that hold code. 'connect' is just a folder.
332341
if (!project.name.equals('connect')) {
333342
apply plugin: 'eclipse'

gradle/dependencies.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ versions += [
6060
commonsLang: "3.18.0",
6161
commonsValidator: "1.10.0",
6262
classgraph: "4.8.179",
63-
gradle: "8.14.3",
63+
gradle: "9.1.0",
6464
grgit: "4.1.1",
6565
httpclient: "4.5.14",
6666
jackson: "2.19.0",
@@ -125,7 +125,7 @@ versions += [
125125
snappy: "1.1.10.7",
126126
spotbugs: "4.9.4",
127127
mockOAuth2Server: "2.2.1",
128-
zinc: "1.9.2",
128+
zinc: "1.10.8",
129129
// When updating the zstd version, please do as well in docker/native/native-image-configs/resource-config.json
130130
// Also make sure the compression levels in org.apache.kafka.common.record.CompressionType are still valid
131131
zstd: "1.5.6-10",

gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionSha256Sum=bd71102213493060956ec229d946beee57158dbd89d0e62b91bca0fa2c5f3531
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
3+
distributionSha256Sum=a17ddd85a26b6a7f5ddb71ff8b05fc5104c0202c6e64782429790c933686c806
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
55
networkTimeout=10000
66
validateDistributionUrl=true
77
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
#
4-
# Copyright © 2015-2021 the original authors.
4+
# Copyright © 2015 the original authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
8890

8991
# Use the maximum available, or set MAX_FD != -1 to use that value.
9092
MAX_FD=maximum
@@ -113,20 +115,6 @@ case "$( uname )" in #(
113115
esac
114116

115117

116-
# Loop in case we encounter an error.
117-
for attempt in 1 2 3; do
118-
if [ ! -e "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" ]; then
119-
if ! curl -s -S --retry 3 -L -o "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" "https://raw.githubusercontent.com/gradle/gradle/v8.14.3/gradle/wrapper/gradle-wrapper.jar"; then
120-
rm -f "$APP_HOME/gradle/wrapper/gradle-wrapper.jar"
121-
# Pause for a bit before looping in case the server throttled us.
122-
sleep 5
123-
continue
124-
fi
125-
fi
126-
done
127-
128-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
129-
130118

131119
# Determine the Java command to use to start the JVM.
132120
if [ -n "$JAVA_HOME" ] ; then
@@ -183,7 +171,6 @@ fi
183171
# For Cygwin or MSYS, switch paths to Windows format before running java
184172
if "$cygwin" || "$msys" ; then
185173
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
186-
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
187174

188175
JAVACMD=$( cygpath --unix "$JAVACMD" )
189176

@@ -212,19 +199,31 @@ if "$cygwin" || "$msys" ; then
212199
fi
213200

214201

202+
203+
# Loop in case we encounter an error.
204+
for attempt in 1 2 3; do
205+
if [ ! -e "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" ]; then
206+
if ! curl -s -S --retry 3 -L -o "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" "https://raw.githubusercontent.com/gradle/gradle/v9.1.0/gradle/wrapper/gradle-wrapper.jar"; then
207+
rm -f "$APP_HOME/gradle/wrapper/gradle-wrapper.jar"
208+
# Pause for a bit before looping in case the server throttled us.
209+
sleep 5
210+
continue
211+
fi
212+
fi
213+
done
214+
215215
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
216216
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
217217

218218
# Collect all arguments for the java command:
219-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
219+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
220220
# and any embedded shellness will be escaped.
221221
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
222222
# treated as '${Hostname}' itself on the command line.
223223

224224
set -- \
225225
"-Dorg.gradle.appname=$APP_BASE_NAME" \
226-
-classpath "$CLASSPATH" \
227-
org.gradle.wrapper.GradleWrapperMain \
226+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
228227
"$@"
229228

230229
# Stop when "xargs" is not available.

wrapper.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
// and not the version installed on the machine running the task.
2424
// Read more about the wrapper here: https://docs.gradle.org/current/userguide/gradle_wrapper.html
2525
wrapper {
26-
gradleVersion = project.gradleVersion
26+
gradleVersion = versions.gradle
2727
}
2828

2929
// Custom task to inject support for downloading the gradle wrapper jar if it doesn't exist.
@@ -35,14 +35,12 @@ task bootstrapWrapper() {
3535
def wrapperBasePath = "\$APP_HOME/gradle/wrapper"
3636
def wrapperJarPath = wrapperBasePath + "/gradle-wrapper.jar"
3737

38-
// Add a trailing zero to the version if needed.
39-
def fullVersion = project.gradleVersion.count(".") == 1 ? "${project.gradleVersion}.0" : versions.gradle
4038
// Leverages the wrapper jar checked into the gradle project on github because the jar isn't
4139
// available elsewhere. Using raw.githubusercontent.com instead of github.com because
4240
// github.com servers deprecated TLSv1/TLSv1.1 support some time ago, so older versions
4341
// of curl (built against OpenSSL library that doesn't support TLSv1.2) would fail to
4442
// fetch the jar.
45-
def wrapperBaseUrl = "https://raw.githubusercontent.com/gradle/gradle/v$fullVersion/gradle/wrapper"
43+
def wrapperBaseUrl = "https://raw.githubusercontent.com/gradle/gradle/v$versions.gradle/gradle/wrapper"
4644
def wrapperJarUrl = wrapperBaseUrl + "/gradle-wrapper.jar"
4745

4846
def bootstrapString = """
@@ -59,13 +57,15 @@ task bootstrapWrapper() {
5957
done
6058
""".stripIndent()
6159

60+
String putBootstrapStringAbove = "# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script."
61+
6262
def wrapperScript = wrapper.scriptFile
6363
def wrapperLines = wrapperScript.readLines()
6464
wrapperScript.withPrintWriter { out ->
6565
def bootstrapWritten = false
6666
wrapperLines.each { line ->
6767
// Print the wrapper bootstrap before the first usage of the wrapper jar.
68-
if (!bootstrapWritten && line.contains("gradle-wrapper.jar")) {
68+
if (!bootstrapWritten && line.contains(putBootstrapStringAbove)) {
6969
out.println(bootstrapString)
7070
bootstrapWritten = true
7171
}

0 commit comments

Comments
 (0)