Browse Source

MINOR: Update to Gradle 6.3 (#7677)

* Introduce `gradlewAll` script to replace `*All` tasks since the approach
used by the latter doesn't work since Gradle 6.0 and it's unclear when,
if ever, it will work again ( see https://github.com/gradle/gradle/issues/11301).
* Update release script and README given the above.
* Update zinc to 1.3.5.
* Update gradle-versions-plugin to 0.28.0.

The major improvements in Gradle 6.0 to 6.3 are:
- Improved incremental compilation for Scala
- Support for Java 14 (although some Gradle plugins
like spotBugs may need to be updated or disabled,
will do that separately)
- Improved scalac reporting, warnings are clearly
marked as such, which is very helpful.

Tested `gradlewAll` manually for the commands listed in the README
and release script. For `uploadArchive`, I tested it with a local Maven
repository.

Reviewers: Manikumar Reddy <manikumar.reddy@gmail.com>
pull/8499/merge
Ismael Juma 5 years ago committed by GitHub
parent
commit
d6da0452b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      README.md
  2. 91
      build.gradle
  3. 9
      gradle/dependencies.gradle
  4. 2
      gradle/wrapper/gradle-wrapper.properties
  5. 31
      gradlew
  6. 19
      gradlewAll
  7. 10
      release.py

12
README.md

@ -93,11 +93,11 @@ You can pass either the major version (eg 2.12) or the full version (eg 2.12.7): @@ -93,11 +93,11 @@ You can pass either the major version (eg 2.12) or the full version (eg 2.12.7):
### Running a task with all the scala versions enabled by default ###
Append `All` to the task name:
Invoke the `gradlewAll` script followed by the task(s):
./gradlew testAll
./gradlew jarAll
./gradlew releaseTarGzAll
./gradlewAll test
./gradlewAll jar
./gradlewAll releaseTarGz
### Running a task for a specific project ###
This is for `core`, `examples` and `clients`
@ -119,7 +119,7 @@ build directory (`${project_dir}/bin`) clashes with Kafka's scripts directory an @@ -119,7 +119,7 @@ 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 ###
./gradlew uploadArchivesAll
./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
@ -161,7 +161,7 @@ Please note for this to work you should create/update user maven settings (typic @@ -161,7 +161,7 @@ Please note for this to work you should create/update user maven settings (typic
### Installing the jars to the local Maven repository ###
./gradlew installAll
./gradlewAll install
### Building the test jar ###
./gradlew testJar

91
build.gradle

@ -92,7 +92,7 @@ allprojects { @@ -92,7 +92,7 @@ allprojects {
}
ext {
gradleVersion = "$versions.gradle"
gradleVersion = versions.gradle
minJavaVersion = "8"
buildVersionFileName = "kafka-version.properties"
@ -423,6 +423,11 @@ subprojects { @@ -423,6 +423,11 @@ subprojects {
}
plugins.withType(ScalaPlugin) {
scala {
zincVersion = versions.zinc
}
task scaladocJar(type:Jar) {
classifier = 'scaladoc'
from "$rootDir/LICENSE"
@ -497,7 +502,7 @@ subprojects { @@ -497,7 +502,7 @@ subprojects {
checkstyle {
configFile = new File(rootDir, "checkstyle/checkstyle.xml")
configProperties = checkstyleConfigProperties("import-control.xml")
toolVersion = "$versions.checkstyle"
toolVersion = versions.checkstyle
}
configure(checkstyleMain) {
@ -513,7 +518,7 @@ subprojects { @@ -513,7 +518,7 @@ subprojects {
test.dependsOn('checkstyleMain', 'checkstyleTest')
spotbugs {
toolVersion = "$versions.spotbugs"
toolVersion = versions.spotbugs
excludeFilter = file("$rootDir/gradle/spotbugs-exclude.xml")
ignoreFailures = false
}
@ -533,7 +538,7 @@ subprojects { @@ -533,7 +538,7 @@ subprojects {
apply plugin: "jacoco"
jacoco {
toolVersion = "$versions.jacoco"
toolVersion = versions.jacoco
}
// NOTE: Jacoco Gradle plugin does not support "offline instrumentation" this means that classes mocked by PowerMock
@ -643,52 +648,6 @@ task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) { @@ -643,52 +648,6 @@ task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
task reportCoverage(dependsOn: ['jacocoRootReport', 'core:reportCoverage'])
for ( sv in availableScalaVersions ) {
String taskSuffix = sv.replaceAll("\\.", "_")
tasks.create(name: "jarScala_${taskSuffix}", type: GradleBuild) {
startParameter = project.getGradle().getStartParameter().newInstance()
startParameter.projectProperties += [scalaVersion: "${sv}"]
tasks = ['core:jar', 'streams:streams-scala:jar']
}
tasks.create(name: "testScala_${taskSuffix}", type: GradleBuild) {
startParameter = project.getGradle().getStartParameter().newInstance()
startParameter.projectProperties += [scalaVersion: "${sv}"]
tasks = ['core:test', 'streams:streams-scala:test']
}
tasks.create(name: "srcJar_${taskSuffix}", type: GradleBuild) {
startParameter = project.getGradle().getStartParameter().newInstance()
startParameter.projectProperties += [scalaVersion: "${sv}"]
tasks = ['core:srcJar', 'streams:streams-scala:srcJar']
}
tasks.create(name: "docsJar_${taskSuffix}", type: GradleBuild) {
startParameter = project.getGradle().getStartParameter().newInstance()
startParameter.projectProperties += [scalaVersion: "${sv}"]
tasks = ['core:docsJar', 'streams:streams-scala:docsJar']
}
tasks.create(name: "install_${taskSuffix}", type: GradleBuild) {
startParameter = project.getGradle().getStartParameter().newInstance()
startParameter.projectProperties += [scalaVersion: "${sv}"]
tasks = ['install']
}
tasks.create(name: "releaseTarGz_${taskSuffix}", type: GradleBuild) {
startParameter = project.getGradle().getStartParameter().newInstance()
startParameter.projectProperties += [scalaVersion: "${sv}"]
tasks = ['releaseTarGz']
}
tasks.create(name: "uploadScalaArchives_${taskSuffix}", type: GradleBuild) {
startParameter = project.getGradle().getStartParameter().newInstance()
startParameter.projectProperties += [scalaVersion: "${sv}"]
tasks = ['core:uploadArchives', 'streams:streams-scala:uploadArchives']
}
}
def connectPkgs = [
'connect:api',
'connect:basic-auth-extension',
@ -700,37 +659,9 @@ def connectPkgs = [ @@ -700,37 +659,9 @@ def connectPkgs = [
'connect:mirror-client'
]
def pkgs = [
'clients',
'examples',
'log4j-appender',
'streams',
'streams:examples',
'streams:streams-scala',
'streams:test-utils',
'tools'
] + connectPkgs
/** Create one task per default Scala version */
def withDefScalaVersions(taskName) {
defaultScalaVersions.collect { taskName + '_' + it.replaceAll('\\.', '_') }
}
tasks.create(name: "jarConnect", dependsOn: connectPkgs.collect { it + ":jar" }) {}
tasks.create(name: "jarAll", dependsOn: withDefScalaVersions('jarScala') + pkgs.collect { it + ":jar" }) { }
tasks.create(name: "srcJarAll", dependsOn: withDefScalaVersions('srcJar') + pkgs.collect { it + ":srcJar" }) { }
tasks.create(name: "docsJarAll", dependsOn: withDefScalaVersions('docsJar') + pkgs.collect { it + ":docsJar" }) { }
tasks.create(name: "testConnect", dependsOn: connectPkgs.collect { it + ":test" }) {}
tasks.create(name: "testAll", dependsOn: withDefScalaVersions('testScala') + pkgs.collect { it + ":test" }) { }
tasks.create(name: "installAll", dependsOn: withDefScalaVersions('install') + pkgs.collect { it + ":install" }) { }
tasks.create(name: "releaseTarGzAll", dependsOn: withDefScalaVersions('releaseTarGz')) { }
tasks.create(name: "uploadArchivesAll", dependsOn: withDefScalaVersions('uploadScalaArchives') + pkgs.collect { it + ":uploadArchives" }) { }
project(':core') {
println "Building project 'core' with Scala version ${versions.scala}"
@ -789,7 +720,7 @@ project(':core') { @@ -789,7 +720,7 @@ project(':core') {
}
scoverage {
scoverageVersion = "$versions.scoverage"
scoverageVersion = versions.scoverage
reportDir = file("${rootProject.buildDir}/scoverage")
highlighting = false
minimumRate = 0.0
@ -1629,7 +1560,7 @@ project(':connect:api') { @@ -1629,7 +1560,7 @@ project(':connect:api') {
}
javadoc {
include "**/org/apache/kafka/connect/**" // needed for the `javadocAll` task
include "**/org/apache/kafka/connect/**" // needed for the `aggregatedJavadoc` task
// The URL structure was changed to include the locale after Java 8
if (JavaVersion.current().isJava11Compatible())
options.links "https://docs.oracle.com/en/java/javase/${JavaVersion.current().majorVersion}/docs/api/"

9
gradle/dependencies.gradle

@ -20,9 +20,7 @@ @@ -20,9 +20,7 @@
ext {
versions = [:]
libs = [:]
// Enabled by default when commands like `testAll` are invoked
defaultScalaVersions = [ '2.12', '2.13' ]
// Available if -PscalaVersion is used. This is useful when we want to support a Scala version that has
// a higher minimum Java requirement than Kafka. This was previously the case for Scala 2.12 and Java 7.
availableScalaVersions = [ '2.12', '2.13' ]
@ -63,8 +61,8 @@ versions += [ @@ -63,8 +61,8 @@ versions += [
bcpkix: "1.64",
checkstyle: "8.20",
commonsCli: "1.4",
gradle: "5.6.2",
gradleVersionsPlugin: "0.27.0",
gradle: "6.3",
gradleVersionsPlugin: "0.28.0",
grgit: "4.0.1",
httpclient: "4.5.11",
easymock: "4.1",
@ -117,6 +115,7 @@ versions += [ @@ -117,6 +115,7 @@ versions += [
spotbugsPlugin: "3.0.0",
spotlessPlugin: "3.27.1",
testRetryPlugin: "1.1.0",
zinc: "1.3.5",
zookeeper: "3.5.7",
zstd: "1.4.4-7"
]

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-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

31
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/v5.6.2/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.3.0/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
@ -167,19 +167,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then @@ -167,19 +167,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@ -188,14 +188,9 @@ save () { @@ -188,14 +188,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

19
gradlewAll

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Convenient way to invoke a gradle command with all Scala versions supported
# by default
./gradlew "$@" -PscalaVersion=2.12 && ./gradlew "$@" -PscalaVersion=2.13

10
release.py

@ -262,7 +262,7 @@ def command_stage_docs(): @@ -262,7 +262,7 @@ def command_stage_docs():
# version due to already having bumped the bugfix version number.
gradle_version_override = docs_release_version(version)
cmd("Building docs", "./gradlew -Pversion=%s clean releaseTarGzAll aggregatedJavadoc" % gradle_version_override, cwd=REPO_HOME, env=jdk8_env)
cmd("Building docs", "./gradlew -Pversion=%s clean aggregatedJavadoc" % gradle_version_override, cwd=REPO_HOME, env=jdk8_env)
docs_tar = os.path.join(REPO_HOME, 'core', 'build', 'distributions', 'kafka_2.12-%s-site-docs.tgz' % gradle_version_override)
@ -594,10 +594,10 @@ params = { 'release_version': release_version, @@ -594,10 +594,10 @@ params = { 'release_version': release_version,
}
cmd("Creating source archive", "git archive --format tar.gz --prefix kafka-%(release_version)s-src/ -o %(artifacts_dir)s/kafka-%(release_version)s-src.tgz %(rc_tag)s" % params)
cmd("Building artifacts", "gradle", cwd=kafka_dir, env=jdk8_env)
cmd("Building artifacts", "./gradlew clean releaseTarGzAll aggregatedJavadoc", cwd=kafka_dir, env=jdk8_env)
cmd("Building artifacts", "./gradlew clean && ./gradlewAll releaseTarGz", cwd=kafka_dir, env=jdk8_env)
cmd("Copying artifacts", "cp %s/core/build/distributions/* %s" % (kafka_dir, artifacts_dir), shell=True)
cmd("Copying artifacts", "cp -R %s/build/docs/javadoc %s" % (kafka_dir, artifacts_dir))
cmd("Building docs", "./gradlew aggregatedJavadoc", cwd=kafka_dir, env=jdk8_env)
cmd("Copying docs", "cp -R %s/build/docs/javadoc %s" % (kafka_dir, artifacts_dir))
for filename in os.listdir(artifacts_dir):
full_path = os.path.join(artifacts_dir, filename)
@ -641,7 +641,7 @@ with open(os.path.expanduser("~/.gradle/gradle.properties")) as f: @@ -641,7 +641,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", "./gradlew uploadArchivesAll", cwd=kafka_dir, env=jdk8_env)
cmd("Building and uploading archives", "./gradlewAll uploadArchives", cwd=kafka_dir, env=jdk8_env)
cmd("Building and uploading archives", "mvn deploy -Pgpg-signing", cwd=streams_quickstart_dir, env=jdk8_env)
release_notification_props = { 'release_version': release_version,

Loading…
Cancel
Save