From 262aa8cd2916032c92891664cd5523f57eb72510 Mon Sep 17 00:00:00 2001 From: dejan2609 Date: Mon, 6 Feb 2023 18:56:01 +0100 Subject: [PATCH] KAFKA-14680: gradle version upgrade 7.6 -->> 8.0.1 Gradle 8 related links: * https://github.com/gradle/gradle/releases/tag/v8.0.0 * https://github.com/gradle/gradle/releases/tag/v8.0.1 * https://docs.gradle.org/8.0.1/userguide/upgrading_version_7.html#changes_8.0 notes: * Javac and Scalac options are reshuffled (workaround for Gradle 8.0.1 bug: https://github.com/gradle/gradle/issues/23962#issuecomment-1437348400) * spotless plugin task reference is removed (newer plugin versions require Java 11, so we can't use them until Kafka 4.0); plugin configuration is kept * jacoco version is bumped: 0.8.7 -->> 0.8.8 https://docs.gradle.org/8.0.1/userguide/jacoco_plugin.html#sec:configuring_the_jacoco_plugin --- build.gradle | 29 +++++++++++++----------- gradle/dependencies.gradle | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 5 ++-- gradlew | 24 ++++++++++++-------- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/build.gradle b/build.gradle index 67fde2455df9..833446e1f8be 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ buildscript { } plugins { - id 'com.diffplug.spotless' version '6.13.0' + id 'com.diffplug.spotless' version '6.13.0' // newer versions require Java 11, so we can't use them until Kafka 4.0 id 'com.github.ben-manes.versions' version '0.44.0' id 'idea' id 'java-library' @@ -54,7 +54,7 @@ spotless { ext { gradleVersion = versions.gradle - minJavaVersion = "8" + minJavaVersion = 8 buildVersionFileName = "kafka-version.properties" defaultMaxHeapSize = "2g" @@ -254,9 +254,6 @@ subprojects { fineTuneEclipseClasspathFile(eclipse, project) } - sourceCompatibility = minJavaVersion - targetCompatibility = minJavaVersion - java { consistentResolution { // resolve the compileClasspath and then "inject" the result of resolution as strict constraints into the runtimeClasspath @@ -273,11 +270,15 @@ subprojects { options.compilerArgs << "-Xlint:-serial" options.compilerArgs << "-Xlint:-try" options.compilerArgs << "-Werror" + // --release is the recommended way to select the target release, but it's only supported in Java 9 so we also - // set --source and --target via `sourceCompatibility` and `targetCompatibility`. If/when Gradle supports `--release` - // natively (https://github.com/gradle/gradle/issues/2510), we should switch to that. - if (JavaVersion.current().isJava9Compatible()) - options.compilerArgs << "--release" << minJavaVersion + // set --source and --target via `sourceCompatibility` and `targetCompatibility`. + if (JavaVersion.current().isJava9Compatible()) { + options.release = minJavaVersion + } else { + sourceCompatibility = minJavaVersion + targetCompatibility = minJavaVersion + } } if (shouldPublish) { @@ -680,9 +681,12 @@ subprojects { ] } - // Scalac's `-release` requires Java 9 or higher - if (JavaVersion.current().isJava9Compatible()) - scalaCompileOptions.additionalParameters += ["-release", minJavaVersion] + // Scalac 2.12 `-release` requires Java 9 or higher, but Scala 2.13 doesn't have that restriction + if (versions.baseScala == "2.13") + scalaCompileOptions.additionalParameters += ["-release:" + minJavaVersion] // Use `:` here to workaround Gradle bug (see https://github.com/gradle/gradle/issues/23962#issuecomment-1437348400) + else if (JavaVersion.current().isJava9Compatible()) + scalaCompileOptions.additionalParameters += ["-release", String.valueOf(minJavaVersion)] // Don't use `:` here as it breaks compilation with Scala 2.12 + configure(scalaCompileOptions.forkOptions) { memoryMaximumSize = defaultMaxHeapSize @@ -2111,7 +2115,6 @@ project(':streams:streams-scala') { dependsOn 'copyDependantLibs' } - test.dependsOn(':spotlessScalaCheck') } project(':streams:test-utils') { diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index ee7ef88e3349..14a2ce223c8d 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -62,13 +62,13 @@ versions += [ checkstyle: "8.36.2", commonsCli: "1.4", dropwizardMetrics: "4.1.12.1", - gradle: "7.6", + gradle: "8.0.1", grgit: "4.1.1", httpclient: "4.5.13", easymock: "4.3", jackson: "2.13.4", jacksonDatabind: "2.13.4.2", - jacoco: "0.8.7", + jacoco: "0.8.8", javassist: "3.27.0-GA", jetty: "9.4.48.v20220622", jersey: "2.34", diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e9ee3c544060..454aca124223 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha=312eb12875e1747e05c2f81a4789902d7e4ec5defbd1eefeaccc08acf096505d -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip +distributionSha=948d1e4ccc2f6ae36cbfa087d827aaca51403acae5411e664a6000bb47946f22 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a2e85319111c..f8fefc72caa8 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -118,7 +118,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/v7.6.0/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/v8.0.1/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 @@ -156,12 +156,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac