aboutsummaryrefslogtreecommitdiffstats
path: root/buildSrc/src/main/groovy/refinery-jmh.gradle
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2021-11-17 03:56:45 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2021-11-17 03:56:45 +0100
commit2457f042578634478965212067df82bef2cb8eb4 (patch)
treecd5e45280f0792333f782109325d04739c86bcb3 /buildSrc/src/main/groovy/refinery-jmh.gradle
parentbuild: merge java and junit conventions (diff)
downloadrefinery-2457f042578634478965212067df82bef2cb8eb4.tar.gz
refinery-2457f042578634478965212067df82bef2cb8eb4.tar.zst
refinery-2457f042578634478965212067df82bef2cb8eb4.zip
build: library and application convetion plugins
Diffstat (limited to 'buildSrc/src/main/groovy/refinery-jmh.gradle')
-rw-r--r--buildSrc/src/main/groovy/refinery-jmh.gradle58
1 files changed, 58 insertions, 0 deletions
diff --git a/buildSrc/src/main/groovy/refinery-jmh.gradle b/buildSrc/src/main/groovy/refinery-jmh.gradle
new file mode 100644
index 00000000..553c469b
--- /dev/null
+++ b/buildSrc/src/main/groovy/refinery-jmh.gradle
@@ -0,0 +1,58 @@
1plugins {
2 id 'org.sonarqube'
3 id 'refinery-java-conventions'
4}
5
6configurations {
7 jmh {
8 extendsFrom implementation
9 }
10}
11
12sourceSets {
13 jmh {
14 java.srcDirs = ['src/jmh/java']
15 resources.srcDirs = ['src/jmh/resources']
16 compileClasspath += sourceSets.main.runtimeClasspath
17 compileClasspath += sourceSets.test.runtimeClasspath
18 }
19}
20
21dependencies {
22 jmhImplementation libs.jmh.core
23 jmhAnnotationProcessor libs.jmh.annprocess
24}
25
26tasks.register('jmh', JavaExec) {
27 dependsOn tasks.named('jmhClasses')
28 main = 'org.openjdk.jmh.Main'
29 classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath
30}
31
32eclipse.classpath {
33 plusConfigurations += [configurations.jmhCompileClasspath, configurations.jmhRuntimeClasspath]
34
35 file.whenMerged { classpath ->
36 for (entry in classpath.entries) {
37 // Workaround from https://github.com/gradle/gradle/issues/4802#issuecomment-407902081
38 if (entry in org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry) {
39 def usedBy = (entry.entryAttributes['gradle_used_by_scope'] ?: '').split(',')
40 if (usedBy == ['jmh']) {
41 // Allow test helper classes to be used in benchmarks from Eclipse
42 // and do not expose JMH dependencies to the main source code.
43 entry.entryAttributes['test'] = true
44 } else if ((usedBy.contains('main') || usedBy.contains('test')) && !usedBy.contains('jmh')) {
45 // main and test sources are also used by jmh sources.
46 usedBy += 'jmh'
47 entry.entryAttributes['gradle_used_by_scope'] = usedBy.join(',')
48 }
49 }
50 }
51 }
52}
53
54sonarqube.properties {
55 properties['sonar.tests'] += [
56 'src/jmh/java',
57 ]
58}