melix / jmh-gradle-plugin

Integrates the JMH benchmarking framework with Gradle
Apache License 2.0
666 stars 88 forks source link

Gradle 6/7 compatibility #166

Closed fleiber closed 3 years ago

fleiber commented 4 years ago

This plugin still works with Gradle 6.x, but uses several deprecated features which are displayed as warning, which will break with Gradle 7.

This is reproduced by launching task jmh with Gradle 6.2 and plugin version 0.5.0.

Here are the Gradle log extracts:

> Configure project :
The jmhRuntime configuration has been deprecated for resolution. This will fail with an error in Gradle 7.0. Please resolve the jmhRuntimeClasspath configuration instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.2.2/userguide/upgrading_version_5.html#dependencies_should_no_longer_be_declared_using_the_compile_and_runtime_configurations
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.warnIfConfigurationIsDeprecatedForResolving(DefaultConfiguration.java:583)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveToStateOrLater(DefaultConfiguration.java:560)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access$1900(DefaultConfiguration.java:141)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getSelectedArtifacts(DefaultConfiguration.java:1246)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.visitContents(DefaultConfiguration.java:1237)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:1226)
    at org.gradle.api.internal.file.AbstractFileCollection.iterator(AbstractFileCollection.java:97)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.iterator(DefaultConfiguration.java:479)
    at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext$FileTreeConverter.convertInto(DefaultFileCollectionResolveContext.java:165)
    at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:103)
    at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveAsFileTrees(DefaultFileCollectionResolveContext.java:89)
    at org.gradle.api.internal.file.AbstractFileCollection$4.visitContents(AbstractFileCollection.java:225)
    at org.gradle.api.internal.file.CompositeFileCollection.getSourceCollections(CompositeFileCollection.java:174)
    at org.gradle.api.internal.file.CompositeFileTree.getSourceCollections(CompositeFileTree.java:39)
    at org.gradle.api.internal.file.CompositeFileCollection.iterator(CompositeFileCollection.java:58)
    at me.champeau.gradle.JMHPlugin$_createStandardJmhJar_closure9$_closure24.doCall(JMHPlugin.groovy:241)
    at me.champeau.gradle.JMHPlugin$_createStandardJmhJar_closure9$_closure24.doCall(JMHPlugin.groovy)

> Task :technical:jmhJar
Copying or archiving duplicate paths with the default duplicates strategy has been deprecated. This is scheduled to be removed in Gradle 7.0. Duplicate path: "META-INF/license.txt". Explicitly set the duplicates strategy to 'DuplicatesStrategy.INCLUDE' if you want to allow duplicate paths. Consult the upgrading guide for further information: https://docs.gradle.org/6.2.2/userguide/upgrading_version_5.html#implicit_duplicate_strategy_for_copy_or_archive_tasks_has_been_deprecated
    at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator.lambda$execute$0(DuplicateHandlingCopyActionDecorator.java:53)
    at org.gradle.api.internal.file.copy.CopyFileVisitorImpl.processFile(CopyFileVisitorImpl.java:64)
    at org.gradle.api.internal.file.copy.CopyFileVisitorImpl.visitFile(CopyFileVisitorImpl.java:48)
    at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTreeImpl$1.visitFile(AbstractFileTree.java:208)
    at org.gradle.api.internal.file.archive.ZipFileTree.visit(ZipFileTree.java:103)
    at org.gradle.api.internal.file.collections.FileTreeAdapter.visit(FileTreeAdapter.java:110)
    at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTreeImpl.visit(AbstractFileTree.java:197)
    at org.gradle.api.internal.file.CompositeFileTree.visit(CompositeFileTree.java:93)

For the second one, it happens multiple times, probably based on all the project dependencies having files with the same path name (so mostly in the standard META-INF folder).

P.S. BTW, jmh could be upgraded (last release is currently 1.23 against 1.21 defined in your plugin).

Thanks!

IRus commented 3 years ago

Two different issues:

  1. The jmhRuntime configuration has been deprecated for resolution
  2. Explicitly set the duplicates strategy to 'DuplicatesStrategy.INCLUDE'
melix commented 3 years ago

I think those issues have been fixed already, but as you make me doubt, I'm checking

IRus commented 3 years ago
id("me.champeau.gradle.jmh").version("0.5.2")
melix commented 3 years ago

Do you by chance have a public build scan you can share?

melix commented 3 years ago

(or a reproducer, because from the code I'm reading, the changes have made into 0.5.2 already)

IRus commented 3 years ago

https://scans.gradle.com/s/f2sib4tasisxy

IRus commented 3 years ago

Only jmh configuration applied:

jmh {
    duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE
}

Because otherwise build fails on Could not expand ZIP: https://github.com/melix/jmh-gradle-plugin/issues/159#issuecomment-579705387

melix commented 3 years ago

Thanks, this is helpful. yes I can reproduce the exclude strategy issue. But not the jmhRuntime one for now :thinking:

IRus commented 3 years ago

Gradle version 6.8.1? This looks simple to me: 'jmhRuntime' runtime is deprecated - https://docs.gradle.org/6.8.1/userguide/upgrading_version_5.html#dependencies_should_no_longer_be_declared_using_the_compile_and_runtime_configurations

https://github.com/melix/jmh-gradle-plugin/blob/master/src/main/groovy/me/champeau/gradle/JMHPlugin.groovy#L51 https://github.com/melix/jmh-gradle-plugin/blob/master/src/main/groovy/me/champeau/gradle/JMHPlugin.groovy#L300

melix commented 3 years ago

The JMH plugin indeed creates a configuration named jmhRuntime, but it's not the deprecated runtime one, it's actually using the "correct" configurations (runtimeClasspath):

https://github.com/melix/jmh-gradle-plugin/blob/58b962aa9cb98755dd196e9c66dd2a80a3c8927a/src/main/groovy/me/champeau/gradle/JMHPlugin.groovy#L305

So I'm quite confused as to why a deprecation warning is issued... And I'm using 7.0 for my tests.

melix commented 3 years ago

Oh I think I understand what's going on. You get a deprecation warning in 6.8.1 because it uses an existing configuration, but in 7.0 it creates a new one so all is good. I'll rename it for clarity, it's a low risk breaking change.

melix commented 3 years ago

Just released 0.5.3 which should fix those issues, thanks for your patience!

IRus commented 3 years ago

Just checked, LGTM. Thanks for your hard work!