diff --git a/build.gradle b/build.gradle index 88324bc313b..4b8dbeb10ab 100644 --- a/build.gradle +++ b/build.gradle @@ -9,8 +9,9 @@ plugins { id "io.freefair.aspectj" version '5.1.1' apply false id "com.github.ben-manes.versions" version '0.28.0' id "com.github.johnrengelman.shadow" version "6.1.0" apply false - id "me.champeau.gradle.jmh" version "0.5.2" apply false + id "me.champeau.jmh" version "0.6.4" apply false id "org.jetbrains.kotlin.plugin.serialization" version "1.4.32" apply false + id "org.unbroken-dome.xjc" version '2.0.0' apply false } ext { diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 1e6b71bc2a8..3a24aaef50f 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -231,7 +231,6 @@ jobs: image: ci-image file: git-repo/ci/tasks/check-project.yml params: - MAIN_TOOLCHAIN: 8 TEST_TOOLCHAIN: 11 <<: *build-project-task-params on_failure: @@ -258,7 +257,6 @@ jobs: image: ci-image file: git-repo/ci/tasks/check-project.yml params: - MAIN_TOOLCHAIN: 8 TEST_TOOLCHAIN: 15 <<: *build-project-task-params on_failure: diff --git a/ci/scripts/check-project.sh b/ci/scripts/check-project.sh index f2bf454e359..7f6ca04cea9 100755 --- a/ci/scripts/check-project.sh +++ b/ci/scripts/check-project.sh @@ -4,6 +4,6 @@ set -e source $(dirname $0)/common.sh pushd git-repo > /dev/null -./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false -Dorg.gradle.java.installations.fromEnv=JDK11,JDK15 \ - -PmainToolchain=$MAIN_TOOLCHAIN -PtestToolchain=$TEST_TOOLCHAIN --no-daemon --max-workers=4 check +./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false -Porg.gradle.java.installations.fromEnv=JDK11,JDK15 \ + -PmainToolchain=${MAIN_TOOLCHAIN} -PtestToolchain=${TEST_TOOLCHAIN} --no-daemon --max-workers=4 check popd > /dev/null diff --git a/gradle/spring-module.gradle b/gradle/spring-module.gradle index 49efaeae84d..e0faef367ad 100644 --- a/gradle/spring-module.gradle +++ b/gradle/spring-module.gradle @@ -4,12 +4,12 @@ apply plugin: 'org.springframework.build.optional-dependencies' // Uncomment the following for Shadow support in the jmhJar block. // Currently commented out due to ZipException: archive is not a ZIP archive // apply plugin: 'com.github.johnrengelman.shadow' -apply plugin: 'me.champeau.gradle.jmh' +apply plugin: 'me.champeau.jmh' apply from: "$rootDir/gradle/publications.gradle" dependencies { - jmh 'org.openjdk.jmh:jmh-core:1.25' - jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.25' + jmh 'org.openjdk.jmh:jmh-core:1.28' + jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.28' jmh 'net.sf.jopt-simple:jopt-simple:4.6' } diff --git a/gradle/toolchains.gradle b/gradle/toolchains.gradle index c6a61fe3841..8f5b5d60b3e 100644 --- a/gradle/toolchains.gradle +++ b/gradle/toolchains.gradle @@ -11,6 +11,8 @@ *
  • a JDK11 toolchain for compiling and running the test SourceSet * * + * By default, the build will fall back to using the current JDK and 1.8 language level for all sourceSets. + * * Gradle will automatically detect JDK distributions in well-known locations. * The following command will list the detected JDKs on the host. * {@code @@ -29,13 +31,34 @@ * @author Brian Clozel */ +def mainToolchainConfigured() { + return project.hasProperty('mainToolchain') && project.mainToolchain +} + +def testToolchainConfigured() { + return project.hasProperty('testToolchain') && project.testToolchain +} + +def mainToolchainLanguageVersion() { + if (mainToolchainConfigured()) { + return JavaLanguageVersion.of(project.mainToolchain.toString()) + } + return JavaLanguageVersion.of(8) +} + +def testToolchainLanguageVersion() { + if (testToolchainConfigured()) { + return JavaLanguageVersion.of(project.testToolchain.toString()) + } + return mainToolchainLanguageVersion() +} + plugins.withType(JavaPlugin) { - // Configure the Java Toolchain if the 'mainToolchain' property is defined - if (project.hasProperty('mainToolchain') && project.mainToolchain) { - def mainLanguageVersion = JavaLanguageVersion.of(project.mainToolchain.toString()) + // Configure the Java Toolchain if the 'mainToolchain' is configured + if (mainToolchainConfigured()) { java { toolchain { - languageVersion = mainLanguageVersion + languageVersion = mainToolchainLanguageVersion() } } } @@ -46,8 +69,8 @@ plugins.withType(JavaPlugin) { } } // Configure a specific Java Toolchain for compiling and running tests if the 'testToolchain' property is defined - if (project.hasProperty('testToolchain') && project.testToolchain) { - def testLanguageVersion = JavaLanguageVersion.of(project.testToolchain.toString()); + if (testToolchainConfigured()) { + def testLanguageVersion = testToolchainLanguageVersion() tasks.withType(JavaCompile).matching { it.name.contains("Test") }.configureEach { javaCompiler = javaToolchains.compilerFor { languageVersion = testLanguageVersion @@ -63,17 +86,17 @@ plugins.withType(JavaPlugin) { plugins.withType(GroovyPlugin) { // Fallback to JDK8 - if (!project.hasProperty('mainToolchain')) { + if (!mainToolchainConfigured()) { compileGroovy { sourceCompatibility = JavaVersion.VERSION_1_8 } } } -// Configure the Kotlin compiler if the 'mainToolchain' property is defined pluginManager.withPlugin("kotlin") { - if (project.hasProperty('mainToolchain') && project.mainToolchain) { - def mainLanguageVersion = JavaLanguageVersion.of(project.mainToolchain.toString()); + // Configure the Kotlin compiler if the 'mainToolchain' property is defined + if (mainToolchainConfigured()) { + def mainLanguageVersion = mainToolchainLanguageVersion() def compiler = javaToolchains.compilerFor { languageVersion = mainLanguageVersion } @@ -107,8 +130,8 @@ pluginManager.withPlugin("kotlin") { } } - if (project.hasProperty('testToolchain') && project.testToolchain) { - def testLanguageVersion = JavaLanguageVersion.of(project.testToolchain.toString()); + if (testToolchainConfigured()) { + def testLanguageVersion = testToolchainLanguageVersion() def compiler = javaToolchains.compilerFor { languageVersion = testLanguageVersion } @@ -121,4 +144,20 @@ pluginManager.withPlugin("kotlin") { } } } +} + +// Configure the JMH plugin to use the toolchain for generating and running JMH bytecode +pluginManager.withPlugin("me.champeau.jmh") { + if (mainToolchainConfigured() || testToolchainConfigured()) { + tasks.matching { it.name.contains('jmh') && it.hasProperty('javaLauncher') }.configureEach { + javaLauncher.set(javaToolchains.launcherFor { + languageVersion.set(testToolchainLanguageVersion()) + }) + } + tasks.withType(JavaCompile).matching { it.name.contains("Jmh") }.configureEach { + javaCompiler = javaToolchains.compilerFor { + languageVersion = testToolchainLanguageVersion() + } + } + } } \ No newline at end of file diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethodTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethodTests.java index 45e78feeff0..cd0143a2cfe 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethodTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethodTests.java @@ -166,7 +166,10 @@ public class InvocableHandlerMethodTests { @SuppressWarnings("unused") - private static class Handler { + static class Handler { + + public Handler() { + } public String handle(Integer intArg, String stringArg) { return intArg + "-" + stringArg; @@ -181,7 +184,7 @@ public class InvocableHandlerMethodTests { } - private static class ExceptionRaisingArgumentResolver implements HandlerMethodArgumentResolver { + static class ExceptionRaisingArgumentResolver implements HandlerMethodArgumentResolver { @Override public boolean supportsParameter(MethodParameter parameter) { diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethodTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethodTests.java index 3f19a54ada9..ead73327bb9 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethodTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethodTests.java @@ -183,6 +183,8 @@ public class InvocableHandlerMethodTests { private AtomicReference result = new AtomicReference<>(); + public Handler() { + } public String getResult() { return this.result.get(); diff --git a/spring-oxm/spring-oxm.gradle b/spring-oxm/spring-oxm.gradle index 9d23276d228..ff0c8abbc88 100644 --- a/spring-oxm/spring-oxm.gradle +++ b/spring-oxm/spring-oxm.gradle @@ -1,56 +1,24 @@ +plugins { + id "org.unbroken-dome.xjc" +} + description = "Spring Object/XML Marshalling" configurations { jibx - xjc } dependencies { jibx "org.jibx:jibx-bind:1.3.3" jibx "org.apache.bcel:bcel:6.0" - xjc "javax.xml.bind:jaxb-api:2.3.1" - xjc "com.sun.xml.bind:jaxb-core:2.3.0.1" - xjc "com.sun.xml.bind:jaxb-impl:2.3.0.1" - xjc "com.sun.xml.bind:jaxb-xjc:2.3.1" - xjc "com.sun.activation:javax.activation:1.2.0" } -ext.genSourcesDir = "${buildDir}/generated-sources" -ext.flightSchema = "${projectDir}/src/test/resources/org/springframework/oxm/flight.xsd" - -task genJaxb { - ext.sourcesDir = "${genSourcesDir}/jaxb" - ext.classesDir = "${buildDir}/classes/jaxb" - - inputs.files(flightSchema).withPathSensitivity(PathSensitivity.RELATIVE) - outputs.dir classesDir - - doLast() { - project.ant { - taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask", - classpath: configurations.xjc.asPath - mkdir(dir: sourcesDir) - mkdir(dir: classesDir) - - xjc(destdir: sourcesDir, schema: flightSchema, - package: "org.springframework.oxm.jaxb.test") { - produces(dir: sourcesDir, includes: "**/*.java") - } - - javac(destdir: classesDir, source: 1.8, target: 1.8, debug: true, - debugLevel: "lines,vars,source", - classpath: configurations.xjc.asPath) { - src(path: sourcesDir) - include(name: "**/*.java") - include(name: "*.java") - } - - copy(todir: classesDir) { - fileset(dir: sourcesDir, erroronmissingdir: false) { - exclude(name: "**/*.java") - } - } - } +xjc { + xjcVersion = '2.2' +} +sourceSets { + test { + xjcTargetPackage = 'org.springframework.oxm.jaxb.test' } } @@ -67,7 +35,7 @@ dependencies { testCompile("org.codehaus.jettison:jettison") { exclude group: "stax", module: "stax-api" } - testCompile(files(genJaxb.classesDir).builtBy(genJaxb)) + //testCompile(files(genJaxb.classesDir).builtBy(genJaxb)) testCompile("org.xmlunit:xmlunit-assertj") testCompile("org.xmlunit:xmlunit-matchers") testRuntime("com.sun.xml.bind:jaxb-core") @@ -76,7 +44,7 @@ dependencies { // JiBX compiler is currently not compatible with JDK 9+. // If customJavaHome has been set, we assume the custom JDK version is 9+. -if ((JavaVersion.current() == JavaVersion.VERSION_1_8) && !System.getProperty("customJavaSourceVersion")) { +if ((JavaVersion.current() == JavaVersion.VERSION_1_8) && !project.hasProperty("testToolchain")) { compileTestJava { def bindingXml = "${projectDir}/src/test/resources/org/springframework/oxm/jibx/binding.xml" diff --git a/spring-oxm/src/test/schema/flight.xsd b/spring-oxm/src/test/schema/flight.xsd new file mode 100644 index 00000000000..f27c3d5ee41 --- /dev/null +++ b/spring-oxm/src/test/schema/flight.xsd @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml index 1d7e1aa0cba..4a6ec9023c3 100644 --- a/src/checkstyle/checkstyle-suppressions.xml +++ b/src/checkstyle/checkstyle-suppressions.xml @@ -6,6 +6,8 @@ + +