Skip to content

Commit e456bc7

Browse files
zchovanattilabukor
authored andcommitted
[build] KUDU-3551 Upgrade gradle to 7.6.4
The current version of gradle is 3+ years old, and the highest Java version supported by it is Java 13, which is ~5years old. Upgrading Kudu's gradle version will make it possible to move from Java8 to a more recently released stable Java version, that would futureproof the Kudu Java client. Gradle 7.6 makes it possible to use up to Java19. Additionally Gradle has fixed multiple security vulnerabilities and issues since 6.8.3 [1] * Gradle version has been upgraded to 7.6.4 from 6.8.3, both in the dependencies declaration and the actual wrapper code itself (/java/gradlew) * Removed jcenter from list of repositories [2] * Replaced compile and testCompile configurations with implementation and testImplementation respectively [3] * Replaced extension methods with archiveExtension [4] * Removed scopes.gradle and the propdeps plugin as optional and provided scopes are no longer supported/working in Gradle7, these have been replaced by either compileOnly * Upgraded scalafmt version [5] * Pinned the scalafmt config to version 1.5.1 to avoid the new formatting errors that popped up with the new scalafmt version * Upgraded Spark3 version to 3.2.4 to solve Guava related compilation errors (some classes have been deprecated and removed, which led to compilation failure) * Updated the shadow plugin version from 6.1.0 to 7.1.2 * Added LogCaptor to resolve issues with CapturingLogAppender, which stopped working in the Scala tests, fixing was taking too much time so this was implemented as a workaround, it only affected 4 tests in TestKuduBackup.scala, if the CLA errors are fixed later, the dependency can be removed and the test changes reverted. * As the legacy maven plugin was removed, the signing and publishing has been rewritten using the new maven-publish plugin. I tested the signing and publishing with a locally hosted Maven repository, however this needs further testing and confirmation from a commiter to ensure it works as expected. The new plugin uses a different task to publish the artifacts (publish instead of uploadArchives) an alias was created to keep backwards compatibility with existing docs/scripts. * The permissions for assign-location.py script were updated, as previously the permissions of it's symlink were copied, but that changed in the new gradle version and the original (non executable) permissions led to test failures. * Two tasks were updated in the shadow.gradle file as well, this needs another round of verification after the jars are built correctly * Dependency scopes were only modified when necessary (compilation failure) Additional manual testing: * Attila Bukor has tested and confirmed that the java artifact signing and publishing works. [1] https://docs.gradle.org/7.6.3/release-notes.html?_gl=1*n7ayww*_ga*MjQ4NTk5ODI5LjE2ODc0MDc0OTA.*_ga_7W7NC6YNPT*MTcxNzc2MzIzOS44NC4xLjE3MTc3NjQyMTUuMjYuMC4w [2] https://docs.gradle.org/6.9.2/userguide/upgrading_version_6.html?_gl=1*1xt1kk*_ga*MjQ4NTk5ODI5LjE2ODc0MDc0OTA.*_ga_7W7NC6YNPT*MTcwNzEyMzc1Ni4zLjEuMTcwNzEyODU2MS41NC4wLjA.#jcenter_deprecation [3] https://docs.gradle.org/6.9.2/userguide/upgrading_version_5.html?_gl=1*1ldn5ls*_ga*MjQ4NTk5ODI5LjE2ODc0MDc0OTA.*_ga_7W7NC6YNPT*MTcwNzEyMzc1Ni4zLjEuMTcwNzEyODY1My40NS4wLjA.#dependencies_should_no_longer_be_declared_using_the_compile_and_runtime_configurations [4] https://docs.gradle.org/6.9.2/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html?_gl=1*1ldn5ls*_ga*MjQ4NTk5ODI5LjE2ODc0MDc0OTA.*_ga_7W7NC6YNPT*MTcwNzEyMzc1Ni4zLjEuMTcwNzEyODY1My40NS4wLjA.#org.gradle.api.tasks.bundling.AbstractArchiveTask:extension [5] alenkacz/gradle-scalafmt#39 Change-Id: I915dab011aba633d55a79c72ea6f459d703d7f47 Reviewed-on: http://gerrit.cloudera.org:8080/21030 Tested-by: Kudu Jenkins Reviewed-by: Attila Bukor <[email protected]>
1 parent 2d9292e commit e456bc7

File tree

27 files changed

+614
-375
lines changed

27 files changed

+614
-375
lines changed

RELEASING.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ Example doc: https://s.apache.org/kudu1.16rn
210210
# Take a note of the identifier of the key you want to use for signing.
211211
gpg --list-secret-keys --keyid-format=short
212212
cd java
213-
./gradlew clean install -PforceSigning -Psigning.gnupg.keyName=<8-character-pgp-key-id>
213+
./gradlew clean assemble -PforceSigning -Psigning.gnupg.keyName=<8-character-pgp-key-id>
214214
----
215215

216216
. Create a new version update commit which removes the -SNAPSHOT suffix (same
@@ -252,19 +252,19 @@ Example doc: https://s.apache.org/kudu1.16rn
252252
# Run a gpg-agent if you don't normally
253253
gpg-agent --daemon
254254
cd java
255-
./gradlew clean assemble
255+
./gradlew clean assemble -PforceSigning -Psigning.gnupg.keyName=<8-character-pgp-key-id>
256256
# Turn off bash history: this is to avoid exposing the credentials
257257
# via .bash_history file.
258258
set +o history
259-
./gradlew --no-parallel uploadArchives \
259+
./gradlew --no-parallel publish \
260260
-Psigning.gnupg.keyName=<8-character-pgp-key-id> \
261261
-PmavenUsername='<APACHE-LDAP-USERNAME>' \
262262
-PmavenPassword='<APACHE-LDAP-PASSWORD>'
263263
# Turn on bash history.
264264
set -o history
265265
----
266266
+
267-
NOTE: If `uploadArchives` is executed without `--no-parallel`, uploading a
267+
NOTE: If `publish` is executed without `--no-parallel`, uploading a
268268
number of artifacts fails with "peer not authenticated" errors.
269269

270270
. Build and deploy new binary test JARs for the RC on macOS and Linux. Build

java/.scalafmt.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
version = 1.5.1 // TODO: remove this and fix the formatting errors
12
style = defaultWithAlign
23

34
align = false

java/build.gradle

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ subprojects {
4848
// These are common to all subprojects. However, subprojects may
4949
// include their own plugins and scripts as well.
5050
apply plugin: "java"
51-
apply from: "$rootDir/gradle/scopes.gradle"
5251
apply from: "$rootDir/gradle/compile.gradle"
5352
apply from: "$rootDir/gradle/tests.gradle"
5453
apply from: "$rootDir/gradle/quality.gradle"
@@ -58,19 +57,17 @@ subprojects {
5857
// Ignore the transitive annotations libraries that are
5958
// not marked as optional in Guava version 22.0+.
6059
// See https://github.com/google/guava/issues/2824
61-
configurations.compile {
60+
configurations.implementation {
6261
exclude group: "com.google.errorprone", module: "error_prone_annotations"
63-
exclude group: "com.google.code.findbugs", module: "jsr305"
6462
exclude group: "com.google.j2objc", module: "j2objc-annotations"
6563
exclude group: "org.checkerframework", module: "checker-compat-qual"
6664
exclude group: "org.codehaus.mojo", module: "animal-sniffer-annotations"
6765
}
6866

69-
sourceSets {
70-
all {
71-
configurations.all { conf ->
72-
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
73-
}
67+
// Force gradle to use the same (declared in dependencies) guava version everywhere
68+
configurations.all {
69+
resolutionStrategy {
70+
force libs.guava
7471
}
7572
}
7673
}
@@ -96,10 +93,7 @@ task javadocAggregate(type: Javadoc, group: "Documentation") {
9693
task copyDistTestJars(type: Copy) {
9794
into "$buildDir/jars/"
9895
from subprojects.collect {
99-
it.configurations.testRuntime
100-
}
101-
from subprojects.collect {
102-
it.configurations.provided
96+
it.configurations.testRuntimeClasspath
10397
}
10498
}
10599

@@ -112,3 +106,8 @@ task distTest(type: DistTestTask, dependsOn: copyDistTestJars) {
112106
}
113107
}
114108
}
109+
110+
// Task alias to keep compatibility with previous Gradle version's publishing plugin
111+
task uploadArchives () {
112+
dependsOn 'publish'
113+
}

java/buildSrc/build.gradle

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,26 @@
1919

2020
repositories {
2121
mavenCentral()
22-
jcenter()
2322
maven { url "https://clojars.org/repo" } // Only used for the clojure plugin below.
2423
maven { url "https://plugins.gradle.org/m2/" }
2524
}
2625

2726
// Manage plugin dependencies since the plugin block can't be used in included build scripts yet.
2827
// For more details see: https://docs.gradle.org/current/userguide/plugins.html#plugins_dsl_limitations
2928
dependencies {
30-
compile "com.github.ben-manes:gradle-versions-plugin:0.41.0"
31-
compile "com.github.jengelman.gradle.plugins:shadow:6.1.0"
32-
compile "gradle.plugin.org.barfuin.gradle.jacocolog:gradle-jacoco-log:1.2.4"
33-
compile "gradle.plugin.com.google.gradle:osdetector-gradle-plugin:1.7.0"
34-
compile "com.google.protobuf:protobuf-gradle-plugin:0.8.18"
35-
compile "com.netflix.nebula:nebula-clojure-plugin:10.1.1"
36-
compile "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.0"
37-
compile "gradle.plugin.cn.bestwu.gradle:propdeps-plugin:0.0.10"
38-
compile "net.ltgt.gradle:gradle-errorprone-plugin:2.0.2"
39-
compile "ru.vyarus:gradle-animalsniffer-plugin:1.5.4"
40-
compile "com.google.code.gson:gson:2.8.9"
41-
compile "cz.alenkacz:gradle-scalafmt:1.14.0"
42-
compile "com.google.guava:guava:31.0.1-jre"
43-
compile "me.champeau.gradle:jmh-gradle-plugin:0.5.3"
29+
implementation "com.github.ben-manes:gradle-versions-plugin:0.41.0"
30+
implementation "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
31+
implementation "gradle.plugin.org.barfuin.gradle.jacocolog:gradle-jacoco-log:1.2.4"
32+
implementation "gradle.plugin.com.google.gradle:osdetector-gradle-plugin:1.7.0"
33+
implementation "com.google.protobuf:protobuf-gradle-plugin:0.8.18"
34+
implementation "com.netflix.nebula:nebula-clojure-plugin:10.1.1"
35+
implementation "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.0"
36+
implementation "net.ltgt.gradle:gradle-errorprone-plugin:2.0.2"
37+
implementation "ru.vyarus:gradle-animalsniffer-plugin:1.5.4"
38+
implementation "com.google.code.gson:gson:2.8.9"
39+
implementation "gradle.plugin.cz.alenkacz:gradle-scalafmt:1.16.2"
40+
implementation "com.google.guava:guava:31.0.1-jre"
41+
implementation "me.champeau.gradle:jmh-gradle-plugin:0.5.3"
4442
}
4543

4644
// Compiler configuration

java/buildSrc/src/main/groovy/org/apache/kudu/gradle/DistTestTask.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ public FileCollection getInputClasses() {
116116
return fc;
117117
}
118118

119+
public File getOutputDir() {
120+
return this.outputDir;
121+
}
122+
119123
@TaskAction
120124
public void doStuff() throws IOException {
121125
getProject().delete(outputDir);

java/gradle/artifacts.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,29 @@ configurations.create("test")
2323
task testJar(type: Jar, dependsOn: testClasses, group: "Build") {
2424
description = "Assembles a jar archive containing the test classes."
2525
from sourceSets.test.output
26-
classifier = "tests"
27-
extension "jar"
26+
archiveClassifier = "tests"
27+
archiveExtension = "jar"
2828
}
2929

3030
task sourcesJar(type: Jar, dependsOn: classes, group: "Build") {
3131
description = "Assembles a jar archive containing the main source."
3232
from sourceSets.main.allSource
33-
classifier "sources"
34-
extension "jar"
33+
archiveClassifier = "sources"
34+
archiveExtension = "jar"
3535
}
3636

3737
task testSourcesJar(type: Jar, dependsOn: testJar, group: "Build") {
3838
description = "Assembles a jar archive containing the test source."
3939
from sourceSets.test.allSource
40-
classifier "test-sources"
41-
extension "jar"
40+
archiveClassifier = "test-sources"
41+
archiveExtension = "jar"
4242
}
4343

4444
task javadocJar(type: Jar, dependsOn: javadoc, group: "Build") {
4545
description = "Assembles a jar archive containing the javadoc."
4646
from javadoc.destinationDir
47-
classifier "javadoc"
48-
extension "jar"
47+
archiveClassifier = "javadoc"
48+
archiveExtension = "jar"
4949
}
5050

5151
tasks.withType(Jar) {

java/gradle/dependencies.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ versions += [
3232
commonsIo : "2.11.0",
3333
errorProne : "2.3.3",
3434
errorProneJavac: "9+181-r4173-1",
35-
gradle : "6.9.2",
35+
gradle : "7.6.4",
3636
guava : "32.1.1-jre",
3737
hadoop : "3.3.1",
3838
hamcrest : "2.2",
@@ -46,6 +46,7 @@ versions += [
4646
jsr305 : "3.0.2",
4747
junit : "4.13.2",
4848
log4j : "2.17.1",
49+
logCaptor : "2.9.2",
4950
micrometer : "1.8.2",
5051
mockito : "4.2.0",
5152
murmur : "1.0.0",
@@ -59,7 +60,7 @@ versions += [
5960
scopt : "4.0.1",
6061
slf4j : "1.7.33",
6162
spark2 : "2.4.8",
62-
spark : "3.1.2",
63+
spark : "3.2.4",
6364
spotBugs : "4.1.1",
6465
yetus : "0.13.0"
6566
]
@@ -112,6 +113,7 @@ libs += [
112113
log4jCompat : "org.apache.logging.log4j:log4j-1.2-api:$versions.log4j",
113114
log4jCore : "org.apache.logging.log4j:log4j-core:$versions.log4j",
114115
log4jSlf4jImpl : "org.apache.logging.log4j:log4j-slf4j-impl:$versions.log4j",
116+
logCaptor : "io.github.hakky54:logcaptor:$versions.logCaptor",
115117
micrometerCore : "io.micrometer:micrometer-core:$versions.micrometer",
116118
mockitoCore : "org.mockito:mockito-core:$versions.mockito",
117119
murmur : "com.sangupta:murmur:$versions.murmur",

java/gradle/publishing.gradle

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
// This file contains common tasks and configuration for artifact publishing.
1919

20-
apply plugin: "maven"
20+
apply plugin: "maven-publish"
2121
apply plugin: "signing"
2222

2323
ext {
@@ -40,51 +40,57 @@ ext {
4040
mavenPassword = propertyWithDefault("mavenPassword", "")
4141
}
4242

43-
uploadArchives {
44-
repositories {
45-
signing {
46-
required { shouldSign }
47-
// Check if we are going to sign, because CI environments may not have
48-
// gpg on their path and useGpgCmd evaluates eagerly.
49-
if (shouldSign) {
50-
useGpgCmd() // Use gpg-agent to sign
43+
publishing {
44+
publications {
45+
maven(MavenPublication) {
46+
from components.java
47+
48+
groupId "org.apache.kudu"
49+
version "${project.version}"
50+
51+
artifact(sourcesJar) {
52+
classifier = "sources"
5153
}
52-
sign configurations.archives
53-
mavenDeployer {
54-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
55-
repository(url: "${mavenPublishUrl}") {
56-
authentication(userName: "${mavenUsername}", password: "${mavenPassword}")
57-
}
58-
afterEvaluate {
59-
pom.project {
60-
url = "$url"
61-
licenses {
62-
license {
63-
name = "The Apache Software License, Version 2.0"
64-
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
65-
distribution = "repo"
66-
}
67-
}
54+
artifact(testSourcesJar) {
55+
classifier = "testSources"
56+
}
57+
artifact(javadocJar) {
58+
classifier = "javadoc"
59+
}
60+
61+
pom {
62+
url = "$url"
63+
licenses {
64+
license {
65+
name = "The Apache License, Version 2.0"
66+
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
67+
distribution = "repo"
6868
}
6969
}
7070
}
7171
}
7272
}
73-
}
74-
75-
// Add the install task to the "Upload" group so it's visible in the tasks output.
76-
install.group = "Upload"
77-
78-
// Sort the generated maven dependencies to make pom comparisons easier.
79-
tasks.withType(Upload) {
80-
def installer = install.repositories.mavenInstaller
81-
def deployer = uploadArchives.repositories.mavenDeployer
8273

83-
[installer, deployer]*.pom*.whenConfigured { pom ->
84-
pom.dependencies = pom.dependencies.sort { dep ->
85-
"$dep.scope:$dep.optional:$dep.groupId:$dep.artifactId"
74+
repositories {
75+
maven {
76+
url "${mavenPublishUrl}"
77+
credentials {
78+
username "${mavenUsername}"
79+
password "${mavenPassword}"
80+
}
8681
}
8782
}
8883
}
8984

85+
signing {
86+
required { shouldSign }
87+
if (shouldSign) {
88+
useGpgCmd() // Use gpg-agent to sign
89+
}
90+
91+
sign configurations.archives
92+
}
93+
94+
// Add the install task to the "Upload" group so it's visible in the tasks output.
95+
publish.group = "Upload"
9096

java/gradle/quality.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if (!propertyExists("skipCodeStyleChecks")) {
4040

4141
checkstyle {
4242
toolVersion = versions.checkstyle
43-
configDir = file("$rootProject.projectDir/config/checkstyle")
43+
configDirectory = file("$rootProject.projectDir/config/checkstyle")
4444
ignoreFailures = ignoreCheckFailures
4545
maxWarnings = 0
4646
showViolations = true

java/gradle/scopes.gradle

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)