aboutsummaryrefslogtreecommitdiffstats
path: root/buildSrc/src/main/groovy/refinery-java-test-fixtures.gradle
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-07-28 12:29:05 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-07-28 12:29:05 +0200
commit94a1e92b5057dccbae582d34592486d4fa74e537 (patch)
treeb6af942707a4992dd2a6a72019715b4116680134 /buildSrc/src/main/groovy/refinery-java-test-fixtures.gradle
parentchore: bump dependencies (diff)
downloadrefinery-94a1e92b5057dccbae582d34592486d4fa74e537.tar.gz
refinery-94a1e92b5057dccbae582d34592486d4fa74e537.tar.zst
refinery-94a1e92b5057dccbae582d34592486d4fa74e537.zip
build: fix testFixtures classpath in eclipse
Diffstat (limited to 'buildSrc/src/main/groovy/refinery-java-test-fixtures.gradle')
-rw-r--r--buildSrc/src/main/groovy/refinery-java-test-fixtures.gradle31
1 files changed, 31 insertions, 0 deletions
diff --git a/buildSrc/src/main/groovy/refinery-java-test-fixtures.gradle b/buildSrc/src/main/groovy/refinery-java-test-fixtures.gradle
new file mode 100644
index 00000000..326fa868
--- /dev/null
+++ b/buildSrc/src/main/groovy/refinery-java-test-fixtures.gradle
@@ -0,0 +1,31 @@
1plugins {
2 id 'java-test-fixtures'
3 id 'refinery-java-conventions'
4}
5
6eclipse.classpath {
7 containsTestFixtures = true
8
9 file.whenMerged { classpath ->
10 def hasTest = classpath.entries.any { entry ->
11 entry in org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry &&
12 entry.entryAttributes['gradle_scope'] == 'test'
13 }
14 for (entry in classpath.entries) {
15 // Workaround https://github.com/gradle/gradle/issues/11845 based on
16 // https://discuss.gradle.org/t/gradle-used-by-scope-not-correctly-generated-when-the-java-test-fixtures-plugin-is-used/39935/2
17 if (entry in org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry) {
18 def usedBy = new LinkedHashSet(
19 Arrays.asList((entry.entryAttributes['gradle_used_by_scope'] ?: '').split(','))
20 )
21 if (usedBy.contains('main')) {
22 usedBy += 'testFixtures'
23 }
24 if (hasTest && usedBy.contains('testFixtures')) {
25 usedBy += 'test'
26 }
27 entry.entryAttributes['gradle_used_by_scope'] = usedBy.join(',')
28 }
29 }
30 }
31}