-
-
Save adorogensky/aa8d99fdb7bef2a1a0f54b84765b2b29 to your computer and use it in GitHub Desktop.
JMH gradle without plugin for multi-module projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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.21' | |
jmhImplementation 'org.openjdk.jmh:jmh-generator-annprocess:1.21' | |
} | |
// 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) | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment