File: groovyProject.gradle

package info (click to toggle)
gradle 4.4.1-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • 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 (133 lines) | stat: -rw-r--r-- 4,602 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import org.gradle.build.ClasspathManifest
import org.gradle.build.DefaultJavaInstallation
import org.gradle.testing.DistributionTest

import org.gradle.internal.jvm.Jvm
import org.gradle.jvm.toolchain.internal.JavaInstallationProbe

import java.util.jar.Attributes

apply plugin: 'groovy'

archivesBaseName = "gradle-${name.replaceAll("\\p{Upper}") { "-${it.toLowerCase()}" }}"

sourceCompatibility = 1.7

def javaInstallationProbe = gradle.services.get(JavaInstallationProbe)

ext {
    compileTasks = tasks.matching { it instanceof JavaCompile || it instanceof GroovyCompile }
    testTasks = tasks.withType(Test)
    javaInstallationForTest = new DefaultJavaInstallation()
    generatedResourcesDir = file("$buildDir/generated-resources/main")
    generatedTestResourcesDir = file("$buildDir/generated-resources/test")
    jarTasks = tasks.withType(Jar)
}

if(!hasProperty("testJavaHome")) {
    ext.testJavaHome = System.getProperty("testJavaHome")
}
if (testJavaHome) {
    def testJavaHomeFile = new File(testJavaHome)
    javaInstallationForTest.javaHome = testJavaHomeFile
    javaInstallationProbe.checkJdk(testJavaHomeFile).configure(javaInstallationForTest)
} else {
    javaInstallationForTest.javaHome = jvm.javaHome
    javaInstallationProbe.current(javaInstallationForTest)
}

dependencies {
    testCompile libraries.junit, libraries.jmock, libraries.spock, libraries.groovy
}

// Extracted as it's also used by buildSrc
apply from: "$rootDir/gradle/compile.gradle"

task classpathManifest(type: ClasspathManifest)

sourceSets {
    main.output.dir generatedResourcesDir, builtBy: classpathManifest
}

testTasks.all { task ->
    maxParallelForks = rootProject.maxParallelForks
    if (isCiServer) {
        def ciProperties = [
            'org.gradle.test.maxParallelForks': maxParallelForks,
            'org.gradle.ci.agentCount': 2,
            'org.gradle.ci.agentNum': rootProject.agentNum,
        ]
        systemProperties(ciProperties)

        // Ignore Forking/agentNum properties in order to be able to pull tests
        if (task instanceof DistributionTest) {
            ciProperties.each { key, value -> task.ignoreSystemProperty(key) }
        } else {
            inputs.property('systemProperties') {
                systemProperties - ciProperties
            }
        }
    }
    executable = Jvm.forHome(javaInstallationForTest.javaHome).javaExecutable
    environment['JAVA_HOME'] = javaInstallationForTest.javaHome.absolutePath
    if (javaInstallationForTest.javaVersion.java7) {
        // enable class unloading
        task.jvmArgs '-XX:+UseConcMarkSweepGC', '-XX:+CMSClassUnloadingEnabled'
    }
    task.inputs.property('javaInstallation') {
        // Includes JVM vendor and major version
        javaInstallationForTest.displayName
    }
    doFirst {
        if (isCiServer) {
            println "maxParallelForks for '$task.path' is $task.maxParallelForks"
        }
    }
}

jarTasks.all { jar ->
    jar.version = baseVersion
    jar.manifest.mainAttributes(
        (Attributes.Name.IMPLEMENTATION_TITLE.toString()): 'Gradle',
        (Attributes.Name.IMPLEMENTATION_VERSION.toString()): baseVersion
    )
}

// Configures the project to use the test fixtures from another project, which by default is core.
// Note this is not used to create test fixtures in this project, see gradle/testFixtures.gradle for that
ext.useTestFixtures = { params = [:] ->
    def projectPath = params.project ?: ":core"
    def sourceSet = params.sourceSet ?: "test"
    def compileConfiguration = sourceSet == "main" ? "compile" : "${sourceSet}Compile"
    def runtimeConfiguration = sourceSet == "main" ? "runtime" : "${sourceSet}Runtime"

    dependencies {
        add(compileConfiguration, project(path: projectPath, configuration: "testFixturesUsageCompile"))
        add(compileConfiguration, project(':internalTesting'))
        add(runtimeConfiguration, project(path: projectPath, configuration: "testFixturesUsageRuntime"))
    }
}

if (file("src/testFixtures").exists()) {
    apply from: "$rootDir/gradle/testFixtures.gradle"
}

if (file("src/integTest").exists()) {
    apply from: "$rootDir/gradle/integTest.gradle"
}

if (file("src/crossVersionTest").exists()) {
    apply from: "$rootDir/gradle/crossVersionTest.gradle"
}

if (file("src/performanceTest").exists()) {
    apply from: "$rootDir/gradle/performanceTest.gradle"
}


apply from: "$rootDir/gradle/distributionTesting.gradle"
apply from: "$rootDir/gradle/intTestImage.gradle"

task compileAll {
    dependsOn tasks.matching { it instanceof JavaCompile || it instanceof GroovyCompile }
}