aboutsummaryrefslogtreecommitdiffstats
path: root/buildSrc/src/main/groovy/refinery-jmh.gradle
diff options
context:
space:
mode:
Diffstat (limited to 'buildSrc/src/main/groovy/refinery-jmh.gradle')
-rw-r--r--buildSrc/src/main/groovy/refinery-jmh.gradle28
1 files changed, 15 insertions, 13 deletions
diff --git a/buildSrc/src/main/groovy/refinery-jmh.gradle b/buildSrc/src/main/groovy/refinery-jmh.gradle
index 48e0c133..17654463 100644
--- a/buildSrc/src/main/groovy/refinery-jmh.gradle
+++ b/buildSrc/src/main/groovy/refinery-jmh.gradle
@@ -29,23 +29,25 @@ tasks.register('jmh', JavaExec) {
29 classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath 29 classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath
30} 30}
31 31
32eclipse.classpath { 32eclipse.classpath.file.whenMerged { classpath ->
33 plusConfigurations += [configurations.jmhCompileClasspath, configurations.jmhRuntimeClasspath] 33 for (entry in classpath.entries) {
34 34 if (entry in org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry) {
35 file.whenMerged { classpath ->
36 for (entry in classpath.entries) {
37 // Workaround from https://github.com/gradle/gradle/issues/4802#issuecomment-407902081 35 // Workaround from https://github.com/gradle/gradle/issues/4802#issuecomment-407902081
38 if (entry in org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry) { 36 if (entry.entryAttributes['gradle_scope'] == 'jmh') {
39 def usedBy = (entry.entryAttributes['gradle_used_by_scope'] ?: '').split(',') 37 // Allow test helper classes to be used in benchmarks from Eclipse
40 if (usedBy == ['jmh']) { 38 // and do not expose JMH dependencies to the main source code.
41 // Allow test helper classes to be used in benchmarks from Eclipse 39 entry.entryAttributes['test'] = true
42 // and do not expose JMH dependencies to the main source code. 40 } else {
43 entry.entryAttributes['test'] = true 41 // Workaround based on
44 } else if ((usedBy.contains('main') || usedBy.contains('test')) && !usedBy.contains('jmh')) { 42 // https://discuss.gradle.org/t/gradle-used-by-scope-not-correctly-generated-when-the-java-test-fixtures-plugin-is-used/39935/2
43 def usedBy = new LinkedHashSet(
44 Arrays.asList((entry.entryAttributes['gradle_used_by_scope'] ?: '').split(','))
45 )
46 if (['main', 'test', 'testFixtures'].any { e -> usedBy.contains(e) }) {
45 // main and test sources are also used by jmh sources. 47 // main and test sources are also used by jmh sources.
46 usedBy += 'jmh' 48 usedBy += 'jmh'
47 entry.entryAttributes['gradle_used_by_scope'] = usedBy.join(',')
48 } 49 }
50 entry.entryAttributes['gradle_used_by_scope'] = usedBy.join(',')
49 } 51 }
50 } 52 }
51 } 53 }