jmh-gradle-plugin
jmh-gradle-plugin copied to clipboard
jmhJar fails due to duplicate classes
For some reason, running jmh task causes two (probably identical) class files to appear per one Java file:
- subproject/build/classes/java/jmh/my/package/jmh/subproject/generated/classname.class
- subproject/build/jmh-generated-classes/my/package/jmh/subproject/generated/classname.class
I'm running JMH task for root project, but plugin and configuration is only applied to one subproject, and appears to be running only for that (as intended). Except, of course, that it does not work - jmhJar cannot deal with two classes with same name, failing the jmh Gradle task.
I have Gradle 4.6, might there some kind of compatibility issue with it? Or are subprojects just not working with this plugin?
+1 This makes the plugin unusable. I can offer a sample project which illustrates the problem if necessary.
The strange thing is that sometimes it works somehow
@denis-zhdanov I eventually hacked around the issue. Not a proper fix, but appears to be working well enough for now:
tasks.getByName('jmhJar').doFirst() {duplicatesStrategy(DuplicatesStrategy.EXCLUDE)}
jmh {
duplicateClassesStrategy = 'exclude'
}
Ran into this as well and couldn't get past it. I ended up going with https://github.com/Valloric/jmh-playground which seems to be a much better solution imo.
@bensku I also 'solved' the problem by finding a combination of gradle and jmh plugin versions which work (with additional setup) - a sample
This is (probably) because you have the jmh-generator-annprocess
dependency in the classpath: the annotation processor therein will generate the benchmarks, then the JMH plugin's own tasks (jmhRunBytecodeGenerator
and jmhCompileGeneratedClasses
) will generate them again, leading to the duplicates.