jmh-gradle-plugin
jmh-gradle-plugin copied to clipboard
"jmhJar" task creates invalid jar
Describe the bug
I want to create a fat jar with jmhJar
because my benchmarks require to load some data from a file,
the jmh
task runs the benchmarks in another directory, which prevents loading data with a relative path.
./gradlew jmhJar
succeeds but running the jar with java -jar build/libs/<jar-name>.jar
fails with the following exception
Exception in thread "main" java.lang.NoClassDefFoundError: joptsimple/OptionException
at org.openjdk.jmh.Main.main(Main.java:41)
Caused by: java.lang.ClassNotFoundException: joptsimple.OptionException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 1 more
I used the shadowJar
plugin, as indicated by the documentation. gradle shadowJar
works, but it builds the main application.
- gradle version: 5.2.1
- plugin version: 0.4.8
- JVM version: 11.07
- OS: Linux 5.3.0-61-generic amd64
I also tried with gradle 5.5 and the plugin version 0.5.0, but then gradle jmh
failed with the following error
Error: Could not find or load main class org.openjdk.jmh.runner.ForkedMain
Caused by: java.lang.ClassNotFoundException: org.openjdk.jmh.runner.ForkedMain
My understanding of the gradle DSL is limited, so here is a link to my build.gradle.