From 11306f16cb583b9ab9a54171a19818fed806f7c8 Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Wed, 21 Aug 2024 12:42:23 +0200 Subject: [PATCH 01/18] Use new shadow plugin coordinates + plugin ID Makes the [new shadow plugin ID](https://github.com/GradleUp/shadow/releases/tag/8.3.0) the default, reference `com.github.johnrengelman.shadow` as the "old" one, remove `io.github.goooler.shadow`. Includes renames of related functional tests. --- build.gradle.kts | 2 +- .../groovy/me/champeau/jmh/AbstractFuncSpec.groovy | 11 +++++------ .../java-project-with-feature-previews/build.gradle | 4 ++-- .../build.gradle | 4 ++-- .../settings.gradle | 2 +- .../me/champeau/gradle/jmh/mixlang/JavaBenchmark.java | 0 .../resources/java-shadow-project/build.gradle | 4 ++-- .../resources/java-shadow-project/settings.gradle | 2 +- .../build.gradle | 2 +- .../settings.gradle | 2 +- .../champeau/gradle/jmh/mixlang/ScalaBenchmark.scala | 0 .../resources/scala-shadow-project/build.gradle | 2 +- .../resources/scala-shadow-project/settings.gradle | 2 +- src/main/groovy/me/champeau/jmh/JMHPlugin.groovy | 2 +- src/test/groovy/me/champeau/jmh/JMHPluginTest.groovy | 4 ++-- 15 files changed, 21 insertions(+), 22 deletions(-) rename src/funcTest/resources/{java-forked-shadow-project => java-shadow-old-project}/build.gradle (95%) rename src/funcTest/resources/{java-forked-shadow-project => java-shadow-old-project}/settings.gradle (92%) rename src/funcTest/resources/{java-forked-shadow-project => java-shadow-old-project}/src/jmh/java/me/champeau/gradle/jmh/mixlang/JavaBenchmark.java (100%) rename src/funcTest/resources/{scala-forked-shadow-project => scala-shadow-old-project}/build.gradle (95%) rename src/funcTest/resources/{scala-forked-shadow-project => scala-shadow-old-project}/settings.gradle (92%) rename src/funcTest/resources/{scala-forked-shadow-project => scala-shadow-old-project}/src/jmh/scala/me/champeau/gradle/jmh/mixlang/ScalaBenchmark.scala (100%) diff --git a/build.gradle.kts b/build.gradle.kts index a46b97f6..4548c83c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -37,8 +37,8 @@ dependencies { testImplementation("org.spockframework:spock-core:2.3-groovy-3.0") { exclude(mapOf("group" to "org.codehaus.groovy")) } + pluginsUnderTest("com.gradleup.shadow:shadow-gradle-plugin:8.3.0") pluginsUnderTest("gradle.plugin.com.github.johnrengelman:shadow:7.1.2") - pluginsUnderTest("io.github.goooler.shadow:shadow-gradle-plugin:8.1.8") testImplementation("org.openjdk.jmh:jmh-core:$jmhVersion") testImplementation("org.openjdk.jmh:jmh-generator-bytecode:$jmhVersion") diff --git a/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy index 4df83dd5..53b88198 100644 --- a/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy @@ -25,19 +25,18 @@ import spock.lang.TempDir abstract class AbstractFuncSpec extends Specification { protected static final List TESTED_GRADLE_VERSIONS = [ - GradleVersion.version('7.0'), - GradleVersion.version('8.0'), + GradleVersion.version('8.3'), GradleVersion.current() ] protected static final List TESTED_SHADOW_PLUGINS = [ - 'com.github.johnrengelman.shadow', - 'io.github.goooler.shadow' + 'com.gradleup.shadow', + 'com.github.johnrengelman.shadow' ] protected static final Map TESTED_SHADOW_PLUGIN_FOLDERS = [ - 'com.github.johnrengelman.shadow': 'shadow', - 'io.github.goooler.shadow': 'forked-shadow' + 'com.gradleup.shadow': 'shadow', + 'com.github.johnrengelman.shadow': 'shadow-old' ] @TempDir diff --git a/src/funcTest/resources/java-project-with-feature-previews/build.gradle b/src/funcTest/resources/java-project-with-feature-previews/build.gradle index 23728d4b..e1eb6a5f 100644 --- a/src/funcTest/resources/java-project-with-feature-previews/build.gradle +++ b/src/funcTest/resources/java-project-with-feature-previews/build.gradle @@ -27,14 +27,14 @@ tasks.withType(JavaCompile).configureEach { options.compilerArgs.add("--enable-preview") javaCompiler.set(javaToolchains.compilerFor { // Using 15 so that we can try a feature preview - languageVersion.set(JavaLanguageVersion.of(15)) + languageVersion.set(JavaLanguageVersion.of(22)) }) } // Then configure the JMH Tasks to build with Java 15 tasks.withType(me.champeau.jmh.WithJavaToolchain).configureEach { javaLauncher.set(javaToolchains.launcherFor { - languageVersion.set(JavaLanguageVersion.of(15)) + languageVersion.set(JavaLanguageVersion.of(22)) }) } diff --git a/src/funcTest/resources/java-forked-shadow-project/build.gradle b/src/funcTest/resources/java-shadow-old-project/build.gradle similarity index 95% rename from src/funcTest/resources/java-forked-shadow-project/build.gradle rename to src/funcTest/resources/java-shadow-old-project/build.gradle index da1e0b0f..a6aa3341 100644 --- a/src/funcTest/resources/java-forked-shadow-project/build.gradle +++ b/src/funcTest/resources/java-shadow-old-project/build.gradle @@ -15,7 +15,7 @@ */ plugins { id 'java' - id 'io.github.goooler.shadow' + id 'com.github.johnrengelman.shadow' id 'me.champeau.jmh' } @@ -26,4 +26,4 @@ repositories { jmh { resultFormat = 'csv' resultsFile = file('build/reports/benchmarks.csv') -} +} \ No newline at end of file diff --git a/src/funcTest/resources/java-forked-shadow-project/settings.gradle b/src/funcTest/resources/java-shadow-old-project/settings.gradle similarity index 92% rename from src/funcTest/resources/java-forked-shadow-project/settings.gradle rename to src/funcTest/resources/java-shadow-old-project/settings.gradle index 0407eef9..0277fce8 100644 --- a/src/funcTest/resources/java-forked-shadow-project/settings.gradle +++ b/src/funcTest/resources/java-shadow-old-project/settings.gradle @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -rootProject.name = "java-forked-shadow-project" \ No newline at end of file +rootProject.name = "java-shadow-project" \ No newline at end of file diff --git a/src/funcTest/resources/java-forked-shadow-project/src/jmh/java/me/champeau/gradle/jmh/mixlang/JavaBenchmark.java b/src/funcTest/resources/java-shadow-old-project/src/jmh/java/me/champeau/gradle/jmh/mixlang/JavaBenchmark.java similarity index 100% rename from src/funcTest/resources/java-forked-shadow-project/src/jmh/java/me/champeau/gradle/jmh/mixlang/JavaBenchmark.java rename to src/funcTest/resources/java-shadow-old-project/src/jmh/java/me/champeau/gradle/jmh/mixlang/JavaBenchmark.java diff --git a/src/funcTest/resources/java-shadow-project/build.gradle b/src/funcTest/resources/java-shadow-project/build.gradle index a6aa3341..cb28cc97 100644 --- a/src/funcTest/resources/java-shadow-project/build.gradle +++ b/src/funcTest/resources/java-shadow-project/build.gradle @@ -15,7 +15,7 @@ */ plugins { id 'java' - id 'com.github.johnrengelman.shadow' + id 'com.gradleup.shadow' id 'me.champeau.jmh' } @@ -26,4 +26,4 @@ repositories { jmh { resultFormat = 'csv' resultsFile = file('build/reports/benchmarks.csv') -} \ No newline at end of file +} diff --git a/src/funcTest/resources/java-shadow-project/settings.gradle b/src/funcTest/resources/java-shadow-project/settings.gradle index 0277fce8..0407eef9 100644 --- a/src/funcTest/resources/java-shadow-project/settings.gradle +++ b/src/funcTest/resources/java-shadow-project/settings.gradle @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -rootProject.name = "java-shadow-project" \ No newline at end of file +rootProject.name = "java-forked-shadow-project" \ No newline at end of file diff --git a/src/funcTest/resources/scala-forked-shadow-project/build.gradle b/src/funcTest/resources/scala-shadow-old-project/build.gradle similarity index 95% rename from src/funcTest/resources/scala-forked-shadow-project/build.gradle rename to src/funcTest/resources/scala-shadow-old-project/build.gradle index a835fa5b..22002eee 100644 --- a/src/funcTest/resources/scala-forked-shadow-project/build.gradle +++ b/src/funcTest/resources/scala-shadow-old-project/build.gradle @@ -15,7 +15,7 @@ */ plugins { id 'scala' - id 'io.github.goooler.shadow' + id 'com.github.johnrengelman.shadow' id 'me.champeau.jmh' } diff --git a/src/funcTest/resources/scala-forked-shadow-project/settings.gradle b/src/funcTest/resources/scala-shadow-old-project/settings.gradle similarity index 92% rename from src/funcTest/resources/scala-forked-shadow-project/settings.gradle rename to src/funcTest/resources/scala-shadow-old-project/settings.gradle index a7c5b5fc..9c8631c9 100644 --- a/src/funcTest/resources/scala-forked-shadow-project/settings.gradle +++ b/src/funcTest/resources/scala-shadow-old-project/settings.gradle @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -rootProject.name = "scala-forked-shadow-project" \ No newline at end of file +rootProject.name = "scala-shadow-project" \ No newline at end of file diff --git a/src/funcTest/resources/scala-forked-shadow-project/src/jmh/scala/me/champeau/gradle/jmh/mixlang/ScalaBenchmark.scala b/src/funcTest/resources/scala-shadow-old-project/src/jmh/scala/me/champeau/gradle/jmh/mixlang/ScalaBenchmark.scala similarity index 100% rename from src/funcTest/resources/scala-forked-shadow-project/src/jmh/scala/me/champeau/gradle/jmh/mixlang/ScalaBenchmark.scala rename to src/funcTest/resources/scala-shadow-old-project/src/jmh/scala/me/champeau/gradle/jmh/mixlang/ScalaBenchmark.scala diff --git a/src/funcTest/resources/scala-shadow-project/build.gradle b/src/funcTest/resources/scala-shadow-project/build.gradle index 22002eee..786e33e6 100644 --- a/src/funcTest/resources/scala-shadow-project/build.gradle +++ b/src/funcTest/resources/scala-shadow-project/build.gradle @@ -15,7 +15,7 @@ */ plugins { id 'scala' - id 'com.github.johnrengelman.shadow' + id 'com.gradleup.shadow' id 'me.champeau.jmh' } diff --git a/src/funcTest/resources/scala-shadow-project/settings.gradle b/src/funcTest/resources/scala-shadow-project/settings.gradle index 9c8631c9..a7c5b5fc 100644 --- a/src/funcTest/resources/scala-shadow-project/settings.gradle +++ b/src/funcTest/resources/scala-shadow-project/settings.gradle @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -rootProject.name = "scala-shadow-project" \ No newline at end of file +rootProject.name = "scala-forked-shadow-project" \ No newline at end of file diff --git a/src/main/groovy/me/champeau/jmh/JMHPlugin.groovy b/src/main/groovy/me/champeau/jmh/JMHPlugin.groovy index b99f3369..7fe14a7e 100644 --- a/src/main/groovy/me/champeau/jmh/JMHPlugin.groovy +++ b/src/main/groovy/me/champeau/jmh/JMHPlugin.groovy @@ -64,7 +64,7 @@ class JMHPlugin implements Plugin { dependencyHandler.addProvider(JMH_NAME, project.providers.provider { "${JMH_CORE_DEPENDENCY}${extension.jmhVersion.get()}" }) {} dependencyHandler.addProvider(JMH_NAME, project.providers.provider { "${JMH_GENERATOR_DEPENDENCY}${extension.jmhVersion.get()}" }) {} - def hasShadow = project.plugins.findPlugin('com.github.johnrengelman.shadow') != null || project.plugins.findPlugin('io.github.goooler.shadow') != null + def hasShadow = project.plugins.findPlugin('com.gradleup.shadow') != null || project.plugins.findPlugin('com.github.johnrengelman.shadow') != null createJmhSourceSet(project) final Configuration runtimeConfiguration = configureJmhRuntimeClasspathConfiguration(project, extension) diff --git a/src/test/groovy/me/champeau/jmh/JMHPluginTest.groovy b/src/test/groovy/me/champeau/jmh/JMHPluginTest.groovy index 47f3e3b0..0f2e3019 100644 --- a/src/test/groovy/me/champeau/jmh/JMHPluginTest.groovy +++ b/src/test/groovy/me/champeau/jmh/JMHPluginTest.groovy @@ -118,8 +118,8 @@ class JMHPluginTest extends Specification { where: shadowPlugin << [ - 'com.github.johnrengelman.shadow', - 'io.github.goooler.shadow' + 'com.gradleup.shadow', + 'com.github.johnrengelman.shadow' ] } From 7f5b5c83650097e98ed30d77e632733f713abf34 Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Wed, 21 Aug 2024 13:18:08 +0200 Subject: [PATCH 02/18] Update src/funcTest/resources/scala-shadow-old-project/build.gradle Co-authored-by: Zongle Wang --- src/funcTest/resources/scala-shadow-old-project/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/funcTest/resources/scala-shadow-old-project/build.gradle b/src/funcTest/resources/scala-shadow-old-project/build.gradle index 22002eee..786e33e6 100644 --- a/src/funcTest/resources/scala-shadow-old-project/build.gradle +++ b/src/funcTest/resources/scala-shadow-old-project/build.gradle @@ -15,7 +15,7 @@ */ plugins { id 'scala' - id 'com.github.johnrengelman.shadow' + id 'com.gradleup.shadow' id 'me.champeau.jmh' } From 18d5d5e1a55aa2f1f75ec64b37d28960b54bebba Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Wed, 21 Aug 2024 13:37:52 +0200 Subject: [PATCH 03/18] Fix CI? --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8ee1a503..c0544c49 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,9 @@ jobs: - uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 21 + java-version: | + 22 + 21 - uses: gradle/actions/setup-gradle@v4 - name: Execute Gradle build run: ./gradlew build From 9b9ea03f83767922b3f4f4aa1234b0b626feae04 Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Wed, 21 Aug 2024 15:04:38 +0200 Subject: [PATCH 04/18] version gates for shadow plugins --- .../me/champeau/jmh/AbstractFuncSpec.groovy | 17 +++++++++++++---- .../champeau/jmh/JmhWithShadowPluginSpec.groovy | 12 +++++++----- .../jmh/ProjectWithDuplicateClassesSpec.groovy | 10 ++-------- .../ProjectWithDuplicateDependenciesSpec.groovy | 5 +---- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy index 53b88198..427d4dcc 100644 --- a/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy @@ -25,13 +25,15 @@ import spock.lang.TempDir abstract class AbstractFuncSpec extends Specification { protected static final List TESTED_GRADLE_VERSIONS = [ - GradleVersion.version('8.3'), + GradleVersion.version('7.0'), + GradleVersion.version('8.0'), GradleVersion.current() ] - protected static final List TESTED_SHADOW_PLUGINS = [ - 'com.gradleup.shadow', - 'com.github.johnrengelman.shadow' + /** Plugin + min Gradle version the plugin supports. */ + protected static final Map TESTED_SHADOW_PLUGINS = [ + 'com.gradleup.shadow': GradleVersion.version('8.3'), + 'com.github.johnrengelman.shadow': GradleVersion.version('8.3') ] protected static final Map TESTED_SHADOW_PLUGIN_FOLDERS = [ @@ -39,6 +41,13 @@ abstract class AbstractFuncSpec extends Specification { 'com.github.johnrengelman.shadow': 'shadow-old' ] + /** List of plugin + Gradle version combinations. */ + protected static final List> TESTED_SHADOW_GRADLE_COMBINATIONS = + TESTED_SHADOW_PLUGINS.collect { shadowGradle -> + TESTED_GRADLE_VERSIONS.findAll { gradle -> gradle >= shadowGradle.value } + .collect { gradle -> new Tuple(shadowGradle.key, gradle) } + }.inject([]) { a, b -> a.addAll(b); a } + @TempDir File temporaryFolder diff --git a/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy index 187601b5..9fb600be 100644 --- a/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy @@ -25,6 +25,9 @@ class JmhWithShadowPluginSpec extends AbstractFuncSpec { def "Run #language benchmarks that are packaged with Shadow plugin (#gradleVersion #language #shadowPlugin)"() { given: + System.err.println("LANG: $language") + System.err.println("G: $gradleVersion") + System.err.println("P: $shadowPlugin") usingSample("${language.toLowerCase()}-${TESTED_SHADOW_PLUGIN_FOLDERS[shadowPlugin]}-project") usingGradleVersion(gradleVersion) withoutConfigurationCache('shadow plugin unsupported') @@ -37,10 +40,9 @@ class JmhWithShadowPluginSpec extends AbstractFuncSpec { benchmarksCsv.text.contains(language + 'Benchmark.sqrtBenchmark') where: - [language, gradleVersion, shadowPlugin] << [ - ['Java', 'Scala'], - TESTED_GRADLE_VERSIONS, - TESTED_SHADOW_PLUGINS - ].combinations() + [language, gradleVersion, shadowPlugin] << + TESTED_SHADOW_GRADLE_COMBINATIONS.collect { plugin, gradle -> + ['Java', 'Scala'].collect { lang -> [lang, gradle, plugin ] } + }.inject([]) { a, b -> a.addAll(b); a } } } diff --git a/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateClassesSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateClassesSpec.groovy index 49e6af69..35cf0a04 100644 --- a/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateClassesSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateClassesSpec.groovy @@ -89,10 +89,7 @@ class ProjectWithDuplicateClassesSpec extends AbstractFuncSpec { result.task(":jmhJar").outcome == FAILED where: - [shadowPlugin, gradleVersion] << [ - TESTED_SHADOW_PLUGINS, - TESTED_GRADLE_VERSIONS - ].combinations() + [shadowPlugin, gradleVersion] << TESTED_SHADOW_GRADLE_COMBINATIONS } def "Show warning for duplicate classes when DuplicatesStrategy.WARN is used (#gradleVersion)"() { @@ -158,10 +155,7 @@ class ProjectWithDuplicateClassesSpec extends AbstractFuncSpec { assertDuplicateClassesWarning(gradleVersion, result.output) where: - [shadowPlugin, gradleVersion] << [ - TESTED_SHADOW_PLUGINS, - TESTED_GRADLE_VERSIONS - ].combinations() + [shadowPlugin, gradleVersion] << TESTED_SHADOW_GRADLE_COMBINATIONS } private static boolean assertDuplicateClassesWarning(GradleVersion gradleVersion, String output) { diff --git a/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateDependenciesSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateDependenciesSpec.groovy index 4ac4c62a..ec6e9830 100644 --- a/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateDependenciesSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateDependenciesSpec.groovy @@ -73,10 +73,7 @@ class ProjectWithDuplicateDependenciesSpec extends AbstractFuncSpec { benchmarksCsv.text.contains('JavaBenchmark.sqrtBenchmark') where: - [shadowPlugin, gradleVersion] << [ - TESTED_SHADOW_PLUGINS, - TESTED_GRADLE_VERSIONS - ].combinations() + [shadowPlugin, gradleVersion] << TESTED_SHADOW_GRADLE_COMBINATIONS } void createBuildFile(String plugins) { From bcc0e97528cb4ce14c89c58ddc2882ad80ff67ce Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Wed, 21 Aug 2024 15:43:26 +0200 Subject: [PATCH 05/18] fix ProjectWithFeaturePreviewSpec --- .../resources/java-project-with-feature-previews/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/src/funcTest/resources/java-project-with-feature-previews/build.gradle b/src/funcTest/resources/java-project-with-feature-previews/build.gradle index e1eb6a5f..c9e7a616 100644 --- a/src/funcTest/resources/java-project-with-feature-previews/build.gradle +++ b/src/funcTest/resources/java-project-with-feature-previews/build.gradle @@ -25,6 +25,7 @@ repositories { // Configure Java compilation tasks to enable feature previews tasks.withType(JavaCompile).configureEach { options.compilerArgs.add("--enable-preview") + options.release = 22 javaCompiler.set(javaToolchains.compilerFor { // Using 15 so that we can try a feature preview languageVersion.set(JavaLanguageVersion.of(22)) From c6fa1b2d65d1ecced5533f4d29ed53958376f6c9 Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Wed, 21 Aug 2024 17:32:33 +0200 Subject: [PATCH 06/18] fix test project names --- src/funcTest/resources/java-shadow-old-project/settings.gradle | 2 +- src/funcTest/resources/java-shadow-project/settings.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/funcTest/resources/java-shadow-old-project/settings.gradle b/src/funcTest/resources/java-shadow-old-project/settings.gradle index 0277fce8..51a3853a 100644 --- a/src/funcTest/resources/java-shadow-old-project/settings.gradle +++ b/src/funcTest/resources/java-shadow-old-project/settings.gradle @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -rootProject.name = "java-shadow-project" \ No newline at end of file +rootProject.name = "java-shadow-old-project" \ No newline at end of file diff --git a/src/funcTest/resources/java-shadow-project/settings.gradle b/src/funcTest/resources/java-shadow-project/settings.gradle index 0407eef9..0277fce8 100644 --- a/src/funcTest/resources/java-shadow-project/settings.gradle +++ b/src/funcTest/resources/java-shadow-project/settings.gradle @@ -13,4 +13,4 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -rootProject.name = "java-forked-shadow-project" \ No newline at end of file +rootProject.name = "java-shadow-project" \ No newline at end of file From ec37b90316838e26accb75dec6e2685c801fbed6 Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Thu, 22 Aug 2024 12:33:22 +0200 Subject: [PATCH 07/18] Update src/funcTest/resources/java-project-with-feature-previews/build.gradle Co-authored-by: Zongle Wang --- .../resources/java-project-with-feature-previews/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/funcTest/resources/java-project-with-feature-previews/build.gradle b/src/funcTest/resources/java-project-with-feature-previews/build.gradle index c9e7a616..d7dfd4c6 100644 --- a/src/funcTest/resources/java-project-with-feature-previews/build.gradle +++ b/src/funcTest/resources/java-project-with-feature-previews/build.gradle @@ -32,7 +32,7 @@ tasks.withType(JavaCompile).configureEach { }) } -// Then configure the JMH Tasks to build with Java 15 +// Then configure the JMH Tasks to build with Java 22 tasks.withType(me.champeau.jmh.WithJavaToolchain).configureEach { javaLauncher.set(javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(22)) From 0942329fbed7a19f0d0f7fa908d3f12e56b6b571 Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Thu, 22 Aug 2024 13:49:23 +0200 Subject: [PATCH 08/18] revert wf change --- .github/workflows/main.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c0544c49..8ee1a503 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,9 +18,7 @@ jobs: - uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: | - 22 - 21 + java-version: 21 - uses: gradle/actions/setup-gradle@v4 - name: Execute Gradle build run: ./gradlew build From b6ffd7c72023b0691edbcdaa725f3e62ae3d849e Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Thu, 22 Aug 2024 13:49:32 +0200 Subject: [PATCH 09/18] update readme --- README.adoc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.adoc b/README.adoc index eaaf2a37..3c692b9a 100644 --- a/README.adoc +++ b/README.adoc @@ -195,9 +195,8 @@ It is possible a dependency on the `test` source set by setting property `includ == Using JMH Gradle Plugin with Shadow Plugin -Optionally it is possible to use the https://github.com/johnrengelman/shadow/[Shadow Plugin] (or the -https://github.com/Goooler/shadow[forked Shadow Plugin]) to do actual JMH jar creation. The configuration of -Shadow Plugin for JMH jar is done via `jmhJar` block. +Optionally it is possible to use the https://github.com/GradleUp/shadow[Shadow Plugin] to do actual JMH jar creation. +The configuration of Shadow Plugin for JMH jar is done via `jmhJar` block. For example: [source,groovy] From 9cd3f75bd6da55b003e2c8445327e2d471119a9a Mon Sep 17 00:00:00 2001 From: Goooler Date: Thu, 22 Aug 2024 09:12:31 +0800 Subject: [PATCH 10/18] FlatMap TESTED_SHADOW_GRADLE_COMBINATIONS --- .../groovy/me/champeau/jmh/AbstractFuncSpec.groovy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy index 427d4dcc..52fca210 100644 --- a/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy @@ -33,7 +33,7 @@ abstract class AbstractFuncSpec extends Specification { /** Plugin + min Gradle version the plugin supports. */ protected static final Map TESTED_SHADOW_PLUGINS = [ 'com.gradleup.shadow': GradleVersion.version('8.3'), - 'com.github.johnrengelman.shadow': GradleVersion.version('8.3') + 'com.github.johnrengelman.shadow': GradleVersion.version('7.0') ] protected static final Map TESTED_SHADOW_PLUGIN_FOLDERS = [ @@ -43,10 +43,10 @@ abstract class AbstractFuncSpec extends Specification { /** List of plugin + Gradle version combinations. */ protected static final List> TESTED_SHADOW_GRADLE_COMBINATIONS = - TESTED_SHADOW_PLUGINS.collect { shadowGradle -> - TESTED_GRADLE_VERSIONS.findAll { gradle -> gradle >= shadowGradle.value } - .collect { gradle -> new Tuple(shadowGradle.key, gradle) } - }.inject([]) { a, b -> a.addAll(b); a } + TESTED_SHADOW_PLUGINS.collect { plugin, minGradle -> + TESTED_GRADLE_VERSIONS.findAll { gradle -> gradle >= minGradle } + .collect { gradle -> Tuple.tuple(plugin, gradle) } + }.collectMany { it } @TempDir File temporaryFolder From e3a2bf252334b7326eb71e4c128faeb5c8758f69 Mon Sep 17 00:00:00 2001 From: Goooler Date: Fri, 23 Aug 2024 11:11:51 +0800 Subject: [PATCH 11/18] Fix scala-shadow-old-project --- src/funcTest/resources/scala-shadow-old-project/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/funcTest/resources/scala-shadow-old-project/build.gradle b/src/funcTest/resources/scala-shadow-old-project/build.gradle index 786e33e6..22002eee 100644 --- a/src/funcTest/resources/scala-shadow-old-project/build.gradle +++ b/src/funcTest/resources/scala-shadow-old-project/build.gradle @@ -15,7 +15,7 @@ */ plugins { id 'scala' - id 'com.gradleup.shadow' + id 'com.github.johnrengelman.shadow' id 'me.champeau.jmh' } From fd8399cf4f8f214e577cfcf64349b7eaaa4e14ad Mon Sep 17 00:00:00 2001 From: Goooler Date: Fri, 23 Aug 2024 11:21:23 +0800 Subject: [PATCH 12/18] Replace plugin ids for sample projects --- .../me/champeau/jmh/AbstractFuncSpec.groovy | 8 +--- .../jmh/JmhWithShadowPluginSpec.groovy | 6 ++- .../java-shadow-old-project/build.gradle | 29 --------------- .../java-shadow-old-project/settings.gradle | 16 -------- .../gradle/jmh/mixlang/JavaBenchmark.java | 36 ------------------ .../java-shadow-project/build.gradle | 2 +- .../scala-shadow-old-project/build.gradle | 33 ----------------- .../scala-shadow-old-project/settings.gradle | 16 -------- .../gradle/jmh/mixlang/ScalaBenchmark.scala | 37 ------------------- .../scala-shadow-project/build.gradle | 2 +- 10 files changed, 9 insertions(+), 176 deletions(-) delete mode 100644 src/funcTest/resources/java-shadow-old-project/build.gradle delete mode 100644 src/funcTest/resources/java-shadow-old-project/settings.gradle delete mode 100644 src/funcTest/resources/java-shadow-old-project/src/jmh/java/me/champeau/gradle/jmh/mixlang/JavaBenchmark.java delete mode 100644 src/funcTest/resources/scala-shadow-old-project/build.gradle delete mode 100644 src/funcTest/resources/scala-shadow-old-project/settings.gradle delete mode 100644 src/funcTest/resources/scala-shadow-old-project/src/jmh/scala/me/champeau/gradle/jmh/mixlang/ScalaBenchmark.scala diff --git a/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy index 52fca210..b8c7bf60 100644 --- a/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy @@ -36,11 +36,6 @@ abstract class AbstractFuncSpec extends Specification { 'com.github.johnrengelman.shadow': GradleVersion.version('7.0') ] - protected static final Map TESTED_SHADOW_PLUGIN_FOLDERS = [ - 'com.gradleup.shadow': 'shadow', - 'com.github.johnrengelman.shadow': 'shadow-old' - ] - /** List of plugin + Gradle version combinations. */ protected static final List> TESTED_SHADOW_GRADLE_COMBINATIONS = TESTED_SHADOW_PLUGINS.collect { plugin, minGradle -> @@ -81,9 +76,10 @@ abstract class AbstractFuncSpec extends Specification { file("build/reports/benchmarks.csv") } - protected void usingSample(String name) { + protected File usingSample(String name) { File sampleDir = new File("src/funcTest/resources/$name") FileUtils.copyDirectory(sampleDir, projectDir) + return sampleDir } protected File file(String path) { diff --git a/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy index 9fb600be..7a12747e 100644 --- a/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy @@ -28,7 +28,11 @@ class JmhWithShadowPluginSpec extends AbstractFuncSpec { System.err.println("LANG: $language") System.err.println("G: $gradleVersion") System.err.println("P: $shadowPlugin") - usingSample("${language.toLowerCase()}-${TESTED_SHADOW_PLUGIN_FOLDERS[shadowPlugin]}-project") + def projectRoot = usingSample("${language.toLowerCase()}-shadow-project") + def rootBuildFile = new File(projectRoot, 'build.gradle') + def buildFileContent = rootBuildFile.text.replace("shadowPlugin", shadowPlugin) + rootBuildFile.text = buildFileContent + usingGradleVersion(gradleVersion) withoutConfigurationCache('shadow plugin unsupported') diff --git a/src/funcTest/resources/java-shadow-old-project/build.gradle b/src/funcTest/resources/java-shadow-old-project/build.gradle deleted file mode 100644 index a6aa3341..00000000 --- a/src/funcTest/resources/java-shadow-old-project/build.gradle +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2014-2021 the original author or authors. - * - * Licensed 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. - */ -plugins { - id 'java' - id 'com.github.johnrengelman.shadow' - id 'me.champeau.jmh' -} - -repositories { - mavenCentral() -} - -jmh { - resultFormat = 'csv' - resultsFile = file('build/reports/benchmarks.csv') -} \ No newline at end of file diff --git a/src/funcTest/resources/java-shadow-old-project/settings.gradle b/src/funcTest/resources/java-shadow-old-project/settings.gradle deleted file mode 100644 index 51a3853a..00000000 --- a/src/funcTest/resources/java-shadow-old-project/settings.gradle +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2014-2021 the original author or authors. - * - * Licensed 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. - */ -rootProject.name = "java-shadow-old-project" \ No newline at end of file diff --git a/src/funcTest/resources/java-shadow-old-project/src/jmh/java/me/champeau/gradle/jmh/mixlang/JavaBenchmark.java b/src/funcTest/resources/java-shadow-old-project/src/jmh/java/me/champeau/gradle/jmh/mixlang/JavaBenchmark.java deleted file mode 100644 index 58873655..00000000 --- a/src/funcTest/resources/java-shadow-old-project/src/jmh/java/me/champeau/gradle/jmh/mixlang/JavaBenchmark.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2014-2021 the original author or authors. - * - * Licensed 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. - */ -package me.champeau.jmh.mixlang; - -import org.openjdk.jmh.annotations.*; - -@State(Scope.Benchmark) -@Fork(1) -@Warmup(iterations = 0) -@Measurement(iterations = 1) -public class JavaBenchmark { - private double value; - - @Setup - public void setUp() { - value = 3.0; - } - - @Benchmark - public double sqrtBenchmark(){ - return Math.sqrt(value); - } -} diff --git a/src/funcTest/resources/java-shadow-project/build.gradle b/src/funcTest/resources/java-shadow-project/build.gradle index cb28cc97..4fdb6794 100644 --- a/src/funcTest/resources/java-shadow-project/build.gradle +++ b/src/funcTest/resources/java-shadow-project/build.gradle @@ -15,7 +15,7 @@ */ plugins { id 'java' - id 'com.gradleup.shadow' + id 'shadowPlugin' id 'me.champeau.jmh' } diff --git a/src/funcTest/resources/scala-shadow-old-project/build.gradle b/src/funcTest/resources/scala-shadow-old-project/build.gradle deleted file mode 100644 index 22002eee..00000000 --- a/src/funcTest/resources/scala-shadow-old-project/build.gradle +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2014-2021 the original author or authors. - * - * Licensed 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. - */ -plugins { - id 'scala' - id 'com.github.johnrengelman.shadow' - id 'me.champeau.jmh' -} - -repositories { - mavenCentral() -} - -dependencies { - implementation 'org.scala-lang:scala-library:2.13.14' -} - -jmh { - resultFormat = 'csv' - resultsFile = file('build/reports/benchmarks.csv') -} \ No newline at end of file diff --git a/src/funcTest/resources/scala-shadow-old-project/settings.gradle b/src/funcTest/resources/scala-shadow-old-project/settings.gradle deleted file mode 100644 index 9c8631c9..00000000 --- a/src/funcTest/resources/scala-shadow-old-project/settings.gradle +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2014-2021 the original author or authors. - * - * Licensed 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. - */ -rootProject.name = "scala-shadow-project" \ No newline at end of file diff --git a/src/funcTest/resources/scala-shadow-old-project/src/jmh/scala/me/champeau/gradle/jmh/mixlang/ScalaBenchmark.scala b/src/funcTest/resources/scala-shadow-old-project/src/jmh/scala/me/champeau/gradle/jmh/mixlang/ScalaBenchmark.scala deleted file mode 100644 index a6dc7b88..00000000 --- a/src/funcTest/resources/scala-shadow-old-project/src/jmh/scala/me/champeau/gradle/jmh/mixlang/ScalaBenchmark.scala +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright 2014-2021 the original author or authors. - * - * Licensed 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. - */ -package me.champeau.jmh.mixlang - -import org.openjdk.jmh.annotations._ - -@State(Scope.Benchmark) -@Fork(1) -@Warmup(iterations = 0) -@Measurement(iterations = 1) -class ScalaBenchmark { - var value: Double = 0 - - @Setup - def setUp(): Unit = { - value = 3.0 - } - - @Benchmark - def sqrtBenchmark(): Double = { - return Math.sqrt(value) - } - -} diff --git a/src/funcTest/resources/scala-shadow-project/build.gradle b/src/funcTest/resources/scala-shadow-project/build.gradle index 786e33e6..9226c0d3 100644 --- a/src/funcTest/resources/scala-shadow-project/build.gradle +++ b/src/funcTest/resources/scala-shadow-project/build.gradle @@ -15,7 +15,7 @@ */ plugins { id 'scala' - id 'com.gradleup.shadow' + id 'shadowPlugin' id 'me.champeau.jmh' } From ceb281f0cfbc40f1e79f837b5af11a04ca1cb300 Mon Sep 17 00:00:00 2001 From: Goooler Date: Fri, 23 Aug 2024 12:25:08 +0800 Subject: [PATCH 13/18] Enable CC for new Shadow --- src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy | 3 +-- .../groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy index b8c7bf60..5b2e9b31 100644 --- a/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy @@ -54,7 +54,6 @@ abstract class AbstractFuncSpec extends Specification { testedGradleVersion = gradleVersion } - // TODO: We can remove this and fully enable CC in tests once bump the Shadow version to 8.1.1+. // TODO: But Kotlin test still fails, it was suppressed in 1bab41646df6f47aea84ea3febeeec1c76cd2e79, need to investigate. protected void withoutConfigurationCache(String reason) { noConfigurationCacheReason = reason @@ -79,7 +78,7 @@ abstract class AbstractFuncSpec extends Specification { protected File usingSample(String name) { File sampleDir = new File("src/funcTest/resources/$name") FileUtils.copyDirectory(sampleDir, projectDir) - return sampleDir + return projectDir } protected File file(String path) { diff --git a/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy index 7a12747e..f77efa1b 100644 --- a/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy @@ -34,7 +34,10 @@ class JmhWithShadowPluginSpec extends AbstractFuncSpec { rootBuildFile.text = buildFileContent usingGradleVersion(gradleVersion) - withoutConfigurationCache('shadow plugin unsupported') + // TODO: com.github.johnrengelman.shadow supports CC from 8.1.1+. + if (shadowPlugin == 'com.github.johnrengelman.shadow') { + withoutConfigurationCache('shadow plugin unsupported') + } when: def result = build("jmh") From c1cfdb20b1d1d56a2e0747746896ad4e6da25864 Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 25 Aug 2024 15:27:36 +0800 Subject: [PATCH 14/18] Swap plugin order --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4548c83c..032af4be 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -37,8 +37,8 @@ dependencies { testImplementation("org.spockframework:spock-core:2.3-groovy-3.0") { exclude(mapOf("group" to "org.codehaus.groovy")) } - pluginsUnderTest("com.gradleup.shadow:shadow-gradle-plugin:8.3.0") pluginsUnderTest("gradle.plugin.com.github.johnrengelman:shadow:7.1.2") + pluginsUnderTest("com.gradleup.shadow:shadow-gradle-plugin:8.3.0") testImplementation("org.openjdk.jmh:jmh-core:$jmhVersion") testImplementation("org.openjdk.jmh:jmh-generator-bytecode:$jmhVersion") From 18eff67541b03d28d27e73d9287fbb5dfc4076bf Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 25 Aug 2024 15:42:48 +0800 Subject: [PATCH 15/18] Simplify test params --- .../me/champeau/jmh/JmhWithShadowPluginSpec.groovy | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy index f77efa1b..414de806 100644 --- a/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy @@ -47,9 +47,12 @@ class JmhWithShadowPluginSpec extends AbstractFuncSpec { benchmarksCsv.text.contains(language + 'Benchmark.sqrtBenchmark') where: - [language, gradleVersion, shadowPlugin] << - TESTED_SHADOW_GRADLE_COMBINATIONS.collect { plugin, gradle -> - ['Java', 'Scala'].collect { lang -> [lang, gradle, plugin ] } - }.inject([]) { a, b -> a.addAll(b); a } + [language, gradleVersion, shadowPlugin] << [ + ['Java', 'Scala'], + TESTED_SHADOW_GRADLE_COMBINATIONS, + ].combinations { lang, tuple -> + def (plugin, gradle) = tuple + [lang, gradle, plugin] + } } } From 907f9db3fda0a346c474a3b428403b0df18dd274 Mon Sep 17 00:00:00 2001 From: Goooler Date: Sun, 25 Aug 2024 16:17:08 +0800 Subject: [PATCH 16/18] Disable CC for com.github.johnrengelman.shadow only --- .../groovy/me/champeau/jmh/AbstractFuncSpec.groovy | 9 +++++++++ .../me/champeau/jmh/JmhWithShadowPluginSpec.groovy | 5 +---- .../champeau/jmh/ProjectWithDuplicateClassesSpec.groovy | 4 ++-- .../jmh/ProjectWithDuplicateDependenciesSpec.groovy | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy index 5b2e9b31..c0b5f0b4 100644 --- a/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/AbstractFuncSpec.groovy @@ -59,6 +59,15 @@ abstract class AbstractFuncSpec extends Specification { noConfigurationCacheReason = reason } + /** + * TODO: remove this once we bumped min Shadow support to 8.1.1 or dropped it. + */ + protected void disableConfigCacheForShadow(String pluginId) { + if (pluginId == 'com.github.johnrengelman.shadow') { + noConfigurationCacheReason = 'com.github.johnrengelman.shadow supports CC from 8.1.1+' + } + } + File getProjectDir() { temporaryFolder } diff --git a/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy index 414de806..b0678887 100644 --- a/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy @@ -34,10 +34,7 @@ class JmhWithShadowPluginSpec extends AbstractFuncSpec { rootBuildFile.text = buildFileContent usingGradleVersion(gradleVersion) - // TODO: com.github.johnrengelman.shadow supports CC from 8.1.1+. - if (shadowPlugin == 'com.github.johnrengelman.shadow') { - withoutConfigurationCache('shadow plugin unsupported') - } + disableConfigCacheForShadow(shadowPlugin) when: def result = build("jmh") diff --git a/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateClassesSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateClassesSpec.groovy index 35cf0a04..4df974d6 100644 --- a/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateClassesSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateClassesSpec.groovy @@ -63,7 +63,7 @@ class ProjectWithDuplicateClassesSpec extends AbstractFuncSpec { given: usingGradleVersion(gradleVersion) - withoutConfigurationCache('shadow plugin unsupported') + disableConfigCacheForShadow(shadowPlugin) and: buildFile << """ @@ -128,7 +128,7 @@ class ProjectWithDuplicateClassesSpec extends AbstractFuncSpec { given: usingGradleVersion(gradleVersion) - withoutConfigurationCache('shadow plugin unsupported') + disableConfigCacheForShadow(shadowPlugin) and: buildFile << """ diff --git a/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateDependenciesSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateDependenciesSpec.groovy index ec6e9830..4daeeb36 100644 --- a/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateDependenciesSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/ProjectWithDuplicateDependenciesSpec.groovy @@ -54,7 +54,7 @@ class ProjectWithDuplicateDependenciesSpec extends AbstractFuncSpec { given: usingGradleVersion(gradleVersion) - withoutConfigurationCache('shadow plugin unsupported') + disableConfigCacheForShadow(shadowPlugin) and: createBuildFile(""" From 6fd4a59632e0da9072a3da8f39d54463c7bd6841 Mon Sep 17 00:00:00 2001 From: Zongle Wang Date: Mon, 26 Aug 2024 15:32:29 +0800 Subject: [PATCH 17/18] Apply suggestions from code review --- .../groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy | 3 --- .../resources/java-project-with-feature-previews/build.gradle | 1 - 2 files changed, 4 deletions(-) diff --git a/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy b/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy index b0678887..df2b7c3c 100644 --- a/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy +++ b/src/funcTest/groovy/me/champeau/jmh/JmhWithShadowPluginSpec.groovy @@ -25,9 +25,6 @@ class JmhWithShadowPluginSpec extends AbstractFuncSpec { def "Run #language benchmarks that are packaged with Shadow plugin (#gradleVersion #language #shadowPlugin)"() { given: - System.err.println("LANG: $language") - System.err.println("G: $gradleVersion") - System.err.println("P: $shadowPlugin") def projectRoot = usingSample("${language.toLowerCase()}-shadow-project") def rootBuildFile = new File(projectRoot, 'build.gradle') def buildFileContent = rootBuildFile.text.replace("shadowPlugin", shadowPlugin) diff --git a/src/funcTest/resources/java-project-with-feature-previews/build.gradle b/src/funcTest/resources/java-project-with-feature-previews/build.gradle index d7dfd4c6..a199b01b 100644 --- a/src/funcTest/resources/java-project-with-feature-previews/build.gradle +++ b/src/funcTest/resources/java-project-with-feature-previews/build.gradle @@ -25,7 +25,6 @@ repositories { // Configure Java compilation tasks to enable feature previews tasks.withType(JavaCompile).configureEach { options.compilerArgs.add("--enable-preview") - options.release = 22 javaCompiler.set(javaToolchains.compilerFor { // Using 15 so that we can try a feature preview languageVersion.set(JavaLanguageVersion.of(22)) From e29afbb6ed36203f69fd9485805315a3cd0be9c8 Mon Sep 17 00:00:00 2001 From: Robert Stupp Date: Mon, 26 Aug 2024 12:53:48 +0200 Subject: [PATCH 18/18] re-add 22 --- .../resources/java-project-with-feature-previews/build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/funcTest/resources/java-project-with-feature-previews/build.gradle b/src/funcTest/resources/java-project-with-feature-previews/build.gradle index a199b01b..01bff374 100644 --- a/src/funcTest/resources/java-project-with-feature-previews/build.gradle +++ b/src/funcTest/resources/java-project-with-feature-previews/build.gradle @@ -25,8 +25,10 @@ repositories { // Configure Java compilation tasks to enable feature previews tasks.withType(JavaCompile).configureEach { options.compilerArgs.add("--enable-preview") + options.release = 22 javaCompiler.set(javaToolchains.compilerFor { - // Using 15 so that we can try a feature preview + // Using 22 so that we can try a feature preview, because + // --enable-preview does not work with 21. languageVersion.set(JavaLanguageVersion.of(22)) }) }