... | |
subprojects { | |
... | |
apply plugin: 'java' | |
apply plugin: 'scala' | |
sourceCompatibility = 1.8 | |
targetCompatibility = 1.8 | |
sourceSets.main { | |
java.srcDirs = ['src/main/java'] | |
scala.srcDirs = ['src/main/scala'] | |
scala.include '**/*.*' | |
} | |
sourceSets.test { | |
java.srcDirs = ['src/test/java'] | |
scala.srcDirs = ['src/test/scala'] | |
scala.include '**/*.*' | |
} | |
// https://docs.gradle.org/current/userguide/building_java_projects.html#sec:java_source_sets | |
sourceSets { | |
jmh { | |
java.srcDirs = ['src/jmh/java'] | |
scala.srcDirs = ['src/jmh/scala'] | |
resources.srcDirs = ['src/jmh/resources'] | |
compileClasspath += sourceSets.main.runtimeClasspath | |
} | |
} | |
dependencies { | |
... | |
jmhImplementation 'org.openjdk.jmh:jmh-core:1.27' | |
jmhAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.27' | |
} | |
// https://docs.gradle.org/current/dsl/org.gradle.api.tasks.JavaExec.html | |
task jmh(type: JavaExec, dependsOn: jmhClasses) { | |
main = 'org.openjdk.jmh.Main' | |
classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath | |
// To enable the built-in stacktrace sampling profiler | |
// args = ['-prof', 'stack'] | |
} | |
// to make sure benchmarks always get compiled | |
classes.finalizedBy(jmhClasses) | |
} | |
... |
This comment has been minimized.
This comment has been minimized.
I have been struggling for a while with the correct build.gradle for a JMH project. Although this snippet shows interesting things I am still having a |
This comment has been minimized.
This comment has been minimized.
@edumucelli, have you tried this https://dev.to/o_a_e/jmh-with-gradle--from-easy-to-simple-52ec ? |
This comment has been minimized.
This comment has been minimized.
@jlussagnet thanks for the suggestion. Yes, I have tried that one too. No lucky yet. The project I am struggling with is at https://github.com/edumucelli/benchmark-xgboost-java if you are feeling generous and want to give it a try, that'd be greatly appreciated :-) |
This comment has been minimized.
This comment has been minimized.
@edumucelli Looking at your code I think the error may be that you only list dependencies for the
to this
Maybe you also need to use |
This comment has been minimized.
This comment has been minimized.
Thanks, @CSchoel! I have had checked your post before and I was not able to make it work as I am not very used to the the Gradle scripting, converting it from Kotlin DSL was also not straightforward for me. However, giving a second try it worked! I have then completely dropped the JMH gradle plugin! Here is the commit. Really appreciated! |
This comment has been minimized.
Since Gradle 4.6 you have to replace
jmhImplementation 'org.openjdk.jmh:jmh-generator-annprocess:1.21'
with
jmhAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.21'