Open sergeykad opened 1 year ago
The workaround is
tasks.jmhCompileGeneratedClasses {
// See https://github.com/melix/jmh-gradle-plugin/issues/248
options.annotationProcessorPath = configurations.jmhAnnotationProcessor.get()
options.errorprone {
// JMH generates duplicate field names like byte p000, p001, p002
disable("HidingField")
}
}
Thanks, @vlsi .
Actually adding the jmhAnnotationProcessor
configuration to the classpath fixed the error: plug-in not found: ErrorProne
issue. I disabled error-prone anyway since I do not want to run it on the generated classes.
I also had to add jmhAnnotationProcessor 'org.apiguardian:apiguardian-api:1.1.2'
, but I am not sure if it is related.
In any case, I think at least part of these changes should be merged into the plugin.
In any case, I think at least part of these changes should be merged into the plugin.
I am not convinced they should. Gradle properly isolates annotation processor dependencies from compile dependencies. The fact that you have to add the annotation processor classes to the compile classpath either means that error prone mixes its annotations with its processor, or that there is a bug in the error prone plugin. In both cases the fix should be on error prone.
@melix , JMH_TASK_COMPILE_GENERATED_CLASSES_NAME
is jmh-gradle-plugin
-specific task that does not account for annotation processors.
I believe error-prone-gradle-plugin properly adds dependencies to jmhAnnotationProcessor
configuration, however, I do not see where jmh-gradle-plugin
picks up the annotation processor configuration and passes it to jmhCompileGeneratedClasses
task.
Does it make sense?
I guess jmh-gradle-plugin
needs something like https://github.com/gradle/gradle/blob/b32b8efd354fbad9921ac5801f86d04ec376a07d/subprojects/plugins/src/main/java/org/gradle/api/plugins/JavaBasePlugin.java#L201, see https://github.com/gradle/gradle/blob/b32b8efd354fbad9921ac5801f86d04ec376a07d/subprojects/plugins/src/main/java/org/gradle/api/plugins/internal/JvmPluginsHelper.java#L87-L92
So a better workaround is
tasks.jmhCompileGeneratedClasses {
options.annotationProcessorPath = configurations.jmhAnnotationProcessor.get()
}
plugins.withId("net.ltgt.errorprone") {
tasks.jmhCompileGeneratedClasses {
options.errorprone {
// JMH generates duplicate field names like byte p000, p001, p002
disable("HidingField")
}
}
}
Describe the bug jmhCompileGeneratedClasses task fails with
error: plug-in not found: ErrorProne
message. There is a similar issue described here: https://github.com/tbroyer/gradle-errorprone-plugin/issues/19To Reproduce Steps to reproduce the behavior:
jmhCompileGeneratedClasses
taskFAILURE: Build failed with an exception.