diff options
author | 2022-02-04 20:18:20 +0100 | |
---|---|---|
committer | 2022-02-04 20:18:20 +0100 | |
commit | 42db1e8b4dcff3667c5f14e8dd464309c3c2f23e (patch) | |
tree | f5f5efe86fb352980cf144cceb68d1a1101b274f /buildSrc/src/main/groovy/refinery-jmh.gradle | |
parent | chore(web): fix Sonar issue (diff) | |
parent | chore(frontend): bump frontend dependencies (diff) | |
download | refinery-42db1e8b4dcff3667c5f14e8dd464309c3c2f23e.tar.gz refinery-42db1e8b4dcff3667c5f14e8dd464309c3c2f23e.tar.zst refinery-42db1e8b4dcff3667c5f14e8dd464309c3c2f23e.zip |
Merge pull request #18 from kris7t/releng-docs
Restructure project
Diffstat (limited to 'buildSrc/src/main/groovy/refinery-jmh.gradle')
-rw-r--r-- | buildSrc/src/main/groovy/refinery-jmh.gradle | 58 |
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..48e0c133 --- /dev/null +++ b/buildSrc/src/main/groovy/refinery-jmh.gradle | |||
@@ -0,0 +1,58 @@ | |||
1 | plugins { | ||
2 | id 'refinery-java-conventions' | ||
3 | id 'refinery-sonarqube' | ||
4 | } | ||
5 | |||
6 | configurations { | ||
7 | jmh { | ||
8 | extendsFrom implementation | ||
9 | } | ||
10 | } | ||
11 | |||
12 | sourceSets { | ||
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 | |||
21 | dependencies { | ||
22 | jmhImplementation libs.jmh.core | ||
23 | jmhAnnotationProcessor libs.jmh.annprocess | ||
24 | } | ||
25 | |||
26 | tasks.register('jmh', JavaExec) { | ||
27 | dependsOn tasks.named('jmhClasses') | ||
28 | main = 'org.openjdk.jmh.Main' | ||
29 | classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath | ||
30 | } | ||
31 | |||
32 | eclipse.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 | |||
54 | sonarqube.properties { | ||
55 | properties['sonar.tests'] += [ | ||
56 | 'src/jmh/java', | ||
57 | ] | ||
58 | } | ||