Skip to content

Instantly share code, notes, and snippets.

@logogin
Created September 3, 2017 17:30
Show Gist options
  • Save logogin/bf201a4d8e9626464e765bf5d8a0e431 to your computer and use it in GitHub Desktop.
Save logogin/bf201a4d8e9626464e765bf5d8a0e431 to your computer and use it in GitHub Desktop.
JMH with shadow configuration
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1'
}
}
plugins {
id "java"
id 'application'
id "com.github.johnrengelman.shadow" version "2.0.1"
//id "me.champeau.gradle.jmh" version "0.4.4"
}
//apply plugin: 'java'
//apply plugin: 'idea'
group = 'me.champeau.sample'
version = '1.0-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
jcenter()
}
sourceSets {
jmh
}
dependencies {
//compile 'com.google.guava:guava:23.0'
compile fileTree(dir: 'libs', include: '*.jar')
jmhCompile project
jmhCompile 'commons-io:commons-io:2.4'
shadow 'junit:junit:3.8.2'
jmhCompile 'org.openjdk.jmh:jmh-core:1.19'
jmhCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.19'
}
//jmh {
// include = '.*'
// humanOutputFile = null
// warmupIterations = 1
// iterations = 1
//}
// it is possible to tweak the jmhJar task directly
//jmhJar.baseName = 'custom'
task inspect {
doFirst {
println project.configurations.compile.files
}
}
mainClassName = "org.openjdk.jmh.Main"
applicationDefaultJvmArgs = []
shadowJar {
classifier = "benchmarks"
from sourceSets.jmh.output
from sourceSets.main.output
from project.configurations.jmhRuntime
manifest.inheritFrom project.tasks.jar.manifest
//manifest.attributes 'Main-Class': 'org.openjdk.jmh.Main'
}
runShadow {
args '-f 5'
}
// http://gvsmirnov.ru/blog/tech/2014/03/10/keeping-your-benchmarks-separate.html
task benchmarks(dependsOn: jmhClasses) {
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'application'
//plugins {
// id "com.github.johnrengelman.shadow" version "2.0.1"
// }
shadowJar {
classifier = "benchmarks"
from sourceSets.jmh.output
from sourceSets.main.output
from project.configurations.jmhRuntime
manifest.inheritFrom project.tasks.jar.manifest
//manifest.attributes 'Main-Class': 'org.openjdk.jmh.Main'
}
doLast {
shadowJar.execute()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment