File: testFixtures.gradle

package info (click to toggle)
gradle 4.4.1-6
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 85,104 kB
  • sloc: java: 319,724; xml: 14,356; cpp: 4,200; ansic: 1,025; sh: 300; makefile: 60; asm: 17; jsp: 17; objc: 10
file content (59 lines) | stat: -rw-r--r-- 2,048 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
    Adds a new testFixtures source set which should contain utilities/fixtures to assist in unit testing
    classes from the main source set.

    The test fixtures are automatically made available to the test classpath.

    The gradle/groovyProject.gradle script automatically applies this if a project has a src/testFixtures dir.
*/
apply plugin: 'java'

configurations {
    outputDirs

    testFixturesCompile.extendsFrom compile
    testFixturesImplementation.extendsFrom implementation
    testFixturesRuntime.extendsFrom runtime

    // Expose configurations that include the test fixture classes for clients to use
    testFixturesUsageCompile.extendsFrom testFixturesCompile, outputDirs
    testFixturesUsageRuntime.extendsFrom testFixturesRuntime, testFixturesUsageCompile

    // Assume that the project wants to use the fixtures for its tests
    testCompile.extendsFrom testFixturesUsageCompile
    testRuntime.extendsFrom testFixturesUsageRuntime
}

sourceSets {
    testFixtures {
        compileClasspath = sourceSets.main.output + configurations.testFixturesCompileClasspath
        runtimeClasspath = output + compileClasspath + configurations.testFixturesRuntimeClasspath
    }
}

dependencies {
    outputDirs sourceSets.testFixtures.output
    testFixturesUsageCompile project(project.path)
    testFixturesCompile libraries.junit, libraries.jmock, libraries.spock
}

plugins.withType(org.gradle.plugins.ide.idea.IdeaPlugin) {
    idea {
        module {
            testSourceDirs += sourceSets.testFixtures.groovy.srcDirs
            testSourceDirs += sourceSets.testFixtures.resources.srcDirs
        }
    }
}

plugins.withType(org.gradle.plugins.ide.eclipse.EclipsePlugin) {
    eclipse {
        classpath {
            plusConfigurations.add(configurations.testFixturesCompile)
            plusConfigurations.add(configurations.testFixturesRuntime)

            //avoiding the certain output directories from the classpath in Eclipse
            minusConfigurations.add(configurations.outputDirs)
        }
    }
}