diff options
Diffstat (limited to 'gradle/jmh.gradle')
-rw-r--r-- | gradle/jmh.gradle | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/gradle/jmh.gradle b/gradle/jmh.gradle index ea88f3e3..9d4d8329 100644 --- a/gradle/jmh.gradle +++ b/gradle/jmh.gradle | |||
@@ -10,31 +10,37 @@ sourceSets { | |||
10 | resources.srcDirs = ['src/jmh/resources'] | 10 | resources.srcDirs = ['src/jmh/resources'] |
11 | compileClasspath += sourceSets.main.runtimeClasspath | 11 | compileClasspath += sourceSets.main.runtimeClasspath |
12 | compileClasspath += sourceSets.test.runtimeClasspath | 12 | compileClasspath += sourceSets.test.runtimeClasspath |
13 | xtendOutputDir = 'src/jmh/xtend-gen' | ||
14 | } | 13 | } |
15 | } | 14 | } |
16 | 15 | ||
17 | dependencies { | 16 | dependencies { |
18 | jmhRuntime "org.openjdk.jmh:jmh-core:${jmhVersion}" | 17 | jmhCompile "org.openjdk.jmh:jmh-core:${jmhVersion}" |
19 | jmhCompile "org.openjdk.jmh:jmh-generator-annprocess:${jmhVersion}" | ||
20 | jmhAnnotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:${jmhVersion}" | 18 | jmhAnnotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:${jmhVersion}" |
21 | } | 19 | } |
22 | 20 | ||
23 | clean.doLast { | ||
24 | delete 'src/jmh/xtend-gen' | ||
25 | } | ||
26 | |||
27 | task jmh(type: JavaExec, dependsOn: jmhClasses) { | 21 | task jmh(type: JavaExec, dependsOn: jmhClasses) { |
28 | main = 'org.openjdk.jmh.Main' | 22 | main = 'org.openjdk.jmh.Main' |
29 | classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath | 23 | classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath |
30 | } | 24 | } |
31 | 25 | ||
32 | eclipse.classpath { | 26 | eclipse.classpath { |
33 | plusConfigurations += [configurations.jmh] | 27 | plusConfigurations += [configurations.jmhCompile, configurations.jmhRuntime] |
34 | 28 | ||
35 | // Allow test helper classes to be used in benchmarks from Eclipse. | ||
36 | file.whenMerged { classpath -> | 29 | file.whenMerged { classpath -> |
37 | def jmhClasspathEntry = classpath.entries.find { entry -> entry.path == 'src/jmh/java' } | 30 | for (entry in classpath.entries) { |
38 | jmhClasspathEntry.entryAttributes['test'] = true | 31 | // Workaround from https://github.com/gradle/gradle/issues/4802#issuecomment-407902081 |
32 | if (entry in org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry) { | ||
33 | def usedBy = (entry.entryAttributes['gradle_used_by_scope'] ?: '').split(',') | ||
34 | if (usedBy == ['jmh']) { | ||
35 | // Allow test helper classes to be used in benchmarks from Eclipse | ||
36 | // and do not expose JMH dependencies to the main source code. | ||
37 | entry.entryAttributes['test'] = true | ||
38 | } else if ((usedBy.contains('main') || usedBy.contains('test')) && !usedBy.contains('jmh')) { | ||
39 | // main and test sources are also used by jmh sources. | ||
40 | usedBy += 'jmh' | ||
41 | entry.entryAttributes['gradle_used_by_scope'] = usedBy.join(',') | ||
42 | } | ||
43 | } | ||
44 | } | ||
39 | } | 45 | } |
40 | } | 46 | } |