Skip to content

Commit

Permalink
Bump to Gradle 7.2, polish build and upgrade plugins/libraries (react…
Browse files Browse the repository at this point in the history
…or#2775)

This commit migrates to Gradle 7.2, and upgrades most plugins (ensuring
compatibility with Gradle 7) and libraries.

As a result, some adjustments had to be made both to the build and to replace
deprecated / removed APIs.

The only exception is Byte Buddy in `reactor-tools`, for which a migration path
isn't simple and will be treated separately in a following commit.

See reactor#2775 for a curated list of changes.
  • Loading branch information
simonbasle authored Sep 24, 2021
1 parent 8d5c9c2 commit d8cf061
Show file tree
Hide file tree
Showing 21 changed files with 135 additions and 121 deletions.
6 changes: 3 additions & 3 deletions benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ dependencies {
// Use the baseline to avoid using new APIs in the benchmarks
compileOnly "io.projectreactor:reactor-core:${perfBaselineVersion}"

implementation "org.openjdk.jmh:jmh-core:1.21"
implementation "org.openjdk.jmh:jmh-core:${jmhVersion}"
implementation "io.projectreactor.addons:reactor-extra:3.3.3.RELEASE", {
exclude group: 'io.projectreactor', module: 'reactor-core'
}
annotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:1.21"
annotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:${jmhVersion}"

current project(':reactor-core')
baseline "io.projectreactor:reactor-core:${perfBaselineVersion}", {
Expand All @@ -28,7 +28,7 @@ dependencies {

task jmhProfilers(type: JavaExec, description:'Lists the available profilers for the jmh task', group: 'Development') {
classpath = sourceSets.main.runtimeClasspath
main = 'org.openjdk.jmh.Main'
mainClass.set('org.openjdk.jmh.Main')
args '-lprof'
}

Expand Down
94 changes: 50 additions & 44 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,36 @@
* limitations under the License.
*/
buildscript {
//we define kotlin version for benefit of both core and test (see kotlin-gradle-plugin below)
ext.kotlinVersion = '1.3.72'
// we define kotlin version for benefit of both core and test (see kotlin-gradle-plugin below)
ext.kotlinVersion = '1.5.31'
repositories {
mavenCentral()
maven { url "https://repo.spring.io/plugins-release" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.24.5" //applied in individual submodules
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.24.18" //applied in individual submodules
}
}


plugins {
id "com.github.johnrengelman.shadow" version "4.0.2"
id 'org.asciidoctor.jvm.convert' version '3.3.0' apply false
id 'org.asciidoctor.jvm.pdf' version '3.3.0' apply false
id "me.champeau.gradle.japicmp" version "0.2.6"
id "de.undercouch.download" version "3.4.3"
id "org.unbroken-dome.test-sets" version "3.0.0" apply false
//note: build scan plugin now must be applied in settings.gradle
//plugin portal is now outdated due to bintray sunset, at least for artifactory gradle plugin
id 'biz.aQute.bnd.builder' version '5.0.1' apply false
id 'io.spring.nohttp' version '0.0.5.RELEASE'
id "com.github.johnrengelman.shadow" version "7.0.0"
id 'org.asciidoctor.jvm.convert' version '3.3.2' apply false
id 'org.asciidoctor.jvm.pdf' version '3.3.2' apply false
id "me.champeau.gradle.japicmp" version "0.3.0"
id "de.undercouch.download" version "4.1.2"
id "org.unbroken-dome.test-sets" version "4.0.0" apply false
// note: build scan plugin now must be applied in settings.gradle
// plugin portal is now outdated due to bintray sunset, at least for artifactory gradle plugin
id 'biz.aQute.bnd.builder' version '5.3.0' apply false
id 'io.spring.nohttp' version '0.0.9'
id "io.github.reyerizo.gradle.jcstress" version "0.8.11" apply false
id "com.diffplug.spotless" version "5.14.0"
id "com.diffplug.spotless" version "5.15.0"
}

apply plugin: "io.reactor.gradle.detect-ci"
apply from: "gradle/asciidoc.gradle" //asciidoc (which is generated from root dir)
apply from: "gradle/asciidoc.gradle" // asciidoc (which is generated from root dir)
apply from: "gradle/releaser.gradle"

repositories { //needed at root for asciidoctor and nohttp-checkstyle
Expand All @@ -65,28 +65,38 @@ ext {
* Versions not necessarily bumped by a script (testing, etc...) below:
*/
// Misc not often upgraded
jsr305Version = '3.0.2'
jsr166BackportVersion = '1.0.0.RELEASE'
// Used as a way to get jsr305 annotations.
// 3.0.1 is the last version that has the 'annotations' jar needed on the compile classpath
findbugsVersion = '3.0.1'

// Blockhound
blockhoundVersion = '1.0.3.RELEASE'
blockhoundVersion = '1.0.6.RELEASE'

// Logging
slf4jVersion = '1.7.12'
logbackVersion = '1.1.2'
slf4jVersion = '1.7.32'
logbackVersion = '1.2.5'

// Testing
jUnitPlatformVersion = '5.6.0'
assertJVersion = '3.19.0' //needs to be manually synchronized in buildSrc
mockitoVersion = '2.23.0'
awaitilityVersion = '3.1.2'
throwingFunctionVersion = '1.5.0'
javaObjectLayoutVersion = '0.9'
testNgVersion = '6.8.5'
jUnitPlatformVersion = '5.8.0' //needs to be manually synchronized in buildSrc
assertJVersion = '3.21.0' //needs to be manually synchronized in buildSrc
mockitoVersion = '3.12.4'
awaitilityVersion = '4.1.0'
throwingFunctionVersion = '1.5.1'
javaObjectLayoutVersion = '0.16'
testNgVersion = '7.4.0'
archUnitVersion = '0.21.0'

// For reactor-tools
byteBuddyVersion = '1.10.9' //sync with plugin version above //TODO bump to 1.11.16 with breaking changes
cgLibVersion = '3.3.0'

// JMH
jmhVersion = '1.33'
}

//only publish scan if a specific gradle entreprise server is passed
//typically, for local usage, you would temporarily set the env with:
// only publish scan if a specific gradle entreprise server is passed
// typically, for local usage, you would temporarily set the env with:
// `GRADLE_ENTERPRISE_URL=https://myge.example.com/ gradle foo`
if (System.getenv('GRADLE_ENTERPRISE_URL')) {
gradleEnterprise {
Expand Down Expand Up @@ -157,24 +167,20 @@ configure(subprojects) { p ->
maven { url 'https://repo.spring.io/milestone' }
}

jacoco {
toolVersion = '0.8.5'
}

jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
xml.required = true
html.required = true
}
}

//includes for base test task (see below for additional common configurations)
// includes for base test task (see below for additional common configurations)
test {
include '**/*Tests.*'
include '**/*Test.*'
}

//all test tasks will show FAILED for each test method,
// all test tasks will show FAILED for each test method,
// common exclusions, no scanning
p.tasks.withType(Test).all {
testLogging {
Expand All @@ -185,10 +191,10 @@ configure(subprojects) { p ->
maxGranularity 3
}

//show progress by displaying test classes, avoiding test suite timeouts
// show progress by displaying test classes, avoiding test suite timeouts
TestDescriptor last
afterTest { TestDescriptor td, TestResult tr ->
if (last != td.getParent()) {
beforeTest { TestDescriptor td ->
if (last != td.getParent() && td.getParent().toString().startsWith("Test class")) {
last = td.getParent()
println last
}
Expand Down Expand Up @@ -216,7 +222,7 @@ configure(subprojects) { p ->
}

if (JavaVersion.current().isJava9Compatible()) {
println "Java 9+: lowering MaxGCPauseMillis to 20ms in ${project.name} ${name}"
println "Java ${JavaVersion.current()}: lowering MaxGCPauseMillis to 20ms in ${project.name} ${name}"
jvmArgs = ["-XX:MaxGCPauseMillis=20"]
}

Expand All @@ -226,11 +232,11 @@ configure(subprojects) { p ->
exclude '**/*Abstract*.*'
exclude '**/*OperatorTest*.*'

//allow re-run of failed tests only without special test tasks failing
// allow re-run of failed tests only without special test tasks failing
// because the filter is too restrictive
filter.setFailOnNoMatchingTests(false)

//display intermediate results for special test tasks
// display intermediate results for special test tasks
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
println('\n' + "${desc} Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)")
Expand All @@ -242,11 +248,11 @@ configure(subprojects) { p ->
assemble.dependsOn docsZip

configure(subprojects) { p ->
//these apply once the above configure is done, but before project-specific build.gradle have applied
// these apply once the above configure is done, but before project-specific build.gradle have applied
apply plugin: "io.reactor.gradle.java-conventions"
apply from: "${rootDir}/gradle/javadoc.gradle"

//these apply AFTER project-specific build.gradle have applied
// these apply AFTER project-specific build.gradle have applied
afterEvaluate {
if (p.plugins.hasPlugin("kotlin")) {
println "Applying Kotlin conventions to ${p.name}"
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ repositories {
}

dependencies {
testImplementation("org.assertj:assertj-core:3.19.0")
testImplementation platform("org.junit:junit-bom:5.6.0")
testImplementation("org.assertj:assertj-core:3.21.0")
testImplementation platform("org.junit:junit-bom:5.8.0")
testImplementation "org.junit.jupiter:junit-jupiter-api"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
}
Expand Down
55 changes: 27 additions & 28 deletions buildSrc/src/main/java/io/reactor/gradle/JavaConventions.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.compile.JavaCompile;

/**
Expand All @@ -38,37 +38,36 @@ public void apply(Project project) {
}

private void applyJavaConvention(Project project) {
JavaPluginConvention java = project.getConvention().getPlugin(JavaPluginConvention.class);
JavaPluginExtension java = project.getExtensions().getByType(JavaPluginExtension.class);
java.setSourceCompatibility(JavaVersion.VERSION_1_8);
java.setTargetCompatibility(JavaVersion.VERSION_1_8);

project.getTasks()
.withType(JavaCompile.class)
.forEach(compileTask -> {
compileTask.getOptions().setEncoding("UTF-8");
compileTask.getOptions().setCompilerArgs(Arrays.asList(
"-Xlint:-varargs", // intentionally disabled
"-Xlint:cast",
"-Xlint:classfile",
"-Xlint:dep-ann",
"-Xlint:divzero",
"-Xlint:empty",
"-Xlint:finally",
"-Xlint:overrides",
"-Xlint:path",
"-Xlint:processing",
"-Xlint:static",
"-Xlint:try",
"-Xmaxerrs", "500",
"-Xmaxwarns", "500",
"-Xlint:deprecation",
"-Xlint:unchecked",
"-Xlint:-serial", // intentionally disabled
"-Xlint:-options", // intentionally disabled
"-Xlint:-fallthrough", // intentionally disabled
"-Xlint:-rawtypes" // TODO enable and fix warnings
));
});
.withType(JavaCompile.class)
.forEach(compileTask -> {
compileTask.getOptions().setEncoding("UTF-8");
compileTask.getOptions().setCompilerArgs(Arrays.asList(
"-Xlint:-varargs", // intentionally disabled
"-Xlint:cast",
"-Xlint:classfile",
"-Xlint:dep-ann",
"-Xlint:divzero",
"-Xlint:empty",
"-Xlint:finally",
"-Xlint:overrides",
"-Xlint:path",
"-Xlint:-processing",
"-Xlint:static",
"-Xlint:try",
"-Xlint:deprecation",
"-Xlint:unchecked",
"-Xlint:-serial", // intentionally disabled
"-Xlint:-options", // intentionally disabled
"-Xlint:-fallthrough", // intentionally disabled
"-Xmaxerrs", "500",
"-Xmaxwarns", "1000"
));
});

if (JavaVersion.current().isJava8Compatible()) {
project.getTasks().withType(JavaCompile.class, t -> {
Expand Down
2 changes: 1 addition & 1 deletion gradle/setup.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ if (qualifyVersion("$version") in ["RELEASE", "MILESTONE"] || rootProject.hasPro

signing {
//requiring signature if there is a publish task that is not to MavenLocal
required { gradle.taskGraph.allTasks.any { it.name.toLowerCase().contains("publish") && !it.name.contains("MavenLocal") } }
required { gradle.taskGraph.allTasks.any { it.name.toLowerCase().contains("publish") && !it.name.contains("MavenLocal") && !it.name.contains("MockRepository") } }
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ set CMD_LINE_ARGS=%*

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

Expand Down
6 changes: 3 additions & 3 deletions reactor-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ dependencies {
}

// JSR-305 annotations
compileOnly "com.google.code.findbugs:jsr305:$jsr305Version"
testCompileOnly "com.google.code.findbugs:jsr305:$jsr305Version"
compileOnly "com.google.code.findbugs:jsr305:$findbugsVersion"
testCompileOnly "com.google.code.findbugs:jsr305:$findbugsVersion"

//Optional Logging Operator
compileOnly "org.slf4j:slf4j-api:$slf4jVersion"
Expand Down Expand Up @@ -102,7 +102,7 @@ dependencies {
testImplementation "org.openjdk.jol:jol-core:$javaObjectLayoutVersion"
testImplementation "org.awaitility:awaitility:$awaitilityVersion"
testImplementation "com.pivovarit:throwing-function:$throwingFunctionVersion"
testImplementation "com.tngtech.archunit:archunit:0.12.0"
testImplementation "com.tngtech.archunit:archunit:$archUnitVersion"

// withMicrometerTest is a test-set that validates what happens when micrometer *IS*
// on the classpath. Needs sourceSets.test.output because tests there use helpers like AutoDisposingRule etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import reactor.core.publisher.FluxProcessor;

import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
import static org.assertj.core.api.Assertions.assertThat;

public class CurrentContextArchTest {

Expand All @@ -42,6 +43,11 @@ public class CurrentContextArchTest {
.withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_JARS)
.importPackagesOf(FluxProcessor.class);

@Test
void smokeTestWhereClassesLoaded() {
assertThat(CORE_SUBSCRIBER_CLASSES).isNotEmpty();
}

@Test
public void corePublishersShouldNotUseDefaultCurrentContext() {
classes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,14 @@ public String toString() {

assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> {
assertThat(queueSubscription).isNull();
assertThat(queueSubscription).isSameAs("foo");
})
.withMessage("\n" + "expected: null\n" + "but was : ThisIsNotAQueue");
.withMessage("\n" +
"Expecting actual:\n" +
" \"foo\"\n" +
"and actual:\n" +
" ThisIsNotAQueue\n" +
"to refer to the same object");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void unsubscribingTwiceDoesUnsubscribeOnce() {
public void settingSameDisposableTwiceDoesUnsubscribeIt() {
Disposable underlying = mock(Disposable.class);
sequentialDisposable.update(underlying);
verifyZeroInteractions(underlying);
verifyNoInteractions(underlying);
sequentialDisposable.update(underlying);
verify(underlying).dispose();
}
Expand Down
Loading

0 comments on commit d8cf061

Please sign in to comment.