aboutsummaryrefslogtreecommitdiffstats
path: root/buildSrc/src/main/kotlin/tools/refinery/gradle/java-test-fixtures.gradle.kts
diff options
context:
space:
mode:
Diffstat (limited to 'buildSrc/src/main/kotlin/tools/refinery/gradle/java-test-fixtures.gradle.kts')
-rw-r--r--buildSrc/src/main/kotlin/tools/refinery/gradle/java-test-fixtures.gradle.kts31
1 files changed, 31 insertions, 0 deletions
diff --git a/buildSrc/src/main/kotlin/tools/refinery/gradle/java-test-fixtures.gradle.kts b/buildSrc/src/main/kotlin/tools/refinery/gradle/java-test-fixtures.gradle.kts
new file mode 100644
index 00000000..7e599c3f
--- /dev/null
+++ b/buildSrc/src/main/kotlin/tools/refinery/gradle/java-test-fixtures.gradle.kts
@@ -0,0 +1,31 @@
1package tools.refinery.gradle
2
3import org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry
4import tools.refinery.gradle.utils.EclipseUtils
5
6plugins {
7 `java-test-fixtures`
8 id("tools.refinery.gradle.internal.java-conventions")
9}
10
11eclipse.classpath {
12 containsTestFixtures.set(true)
13
14 EclipseUtils.whenClasspathFileMerged(file) { eclipseClasspath ->
15 val hasTest = eclipseClasspath.entries.any { entry ->
16 entry is AbstractClasspathEntry && entry.entryAttributes["gradle_scope"] == "test"
17 }
18 EclipseUtils.patchClasspathEntries(eclipseClasspath) { entry ->
19 // Workaround https://github.com/gradle/gradle/issues/11845 based on
20 // https://discuss.gradle.org/t/gradle-used-by-scope-not-correctly-generated-when-the-java-test-fixtures-plugin-is-used/39935/2
21 EclipseUtils.patchGradleUsedByScope(entry) { usedBy ->
22 if (usedBy.contains("main")) {
23 usedBy += "testFixtures"
24 }
25 if (hasTest && usedBy.contains("testFixtures")) {
26 usedBy += "test"
27 }
28 }
29 }
30 }
31}