File: compile.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 (63 lines) | stat: -rw-r--r-- 2,269 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
import org.gradle.internal.jvm.Jvm
import org.gradle.jvm.toolchain.internal.JavaInstallationProbe
import org.gradle.jvm.toolchain.internal.LocalJavaInstallation

if (!hasProperty('java7Home')) {
    // We allow the system property and the project property so that it is
    // possible to set compilation with Java 7 from the command line and from gradle.properties.
    // Note that is this needs to work for buildSrc, too. Gradle properties passed
    // on the command line (-P) are not inherited to buildSrc while system properties are.
    ext.java7Home = System.getProperty('java7Home')
}

def javaInstallationProbe = gradle.services.get(JavaInstallationProbe)

ext.jvmForCompilation = Jvm.current()
ext.currentJavaInstallation = new DefaultJavaInstallation()
ext.javaInstallationForCompilation = new DefaultJavaInstallation()
javaInstallationProbe.current(currentJavaInstallation)
javaInstallationProbe.current(javaInstallationForCompilation)

tasks.withType(AbstractCompile) {
    options.fork = true // Always fork compilation
}

if (java7Home) {
    jvmForCompilation = Jvm.forHome(file(java7Home))
    javaInstallationProbe.checkJdk(file(java7Home)).configure(javaInstallationForCompilation)
    tasks.withType(AbstractCompile) {
        options.with {
            fork = true
            forkOptions.javaHome = jvmForCompilation.javaHome
        }
    }
}

rootProject.ext.java7HomeSet = java7Home as boolean

tasks.withType(JavaCompile) {
    options.encoding = 'utf-8'
    // We need to ignore the path warning since the launcher.jar references
    // core.jar and base-services.jar in its Manifest - and these are not present
    // while compiling.
    options.compilerArgs = ['-Xlint:-options', '-Xlint:-path']
    options.incremental = true
    inputs.property('javaInstallation') {
        javaInstallationForCompilation.displayName
    }
}
tasks.withType(GroovyCompile) {
    options.encoding = 'utf-8'
    options.compilerArgs = ['-Xlint:-options', '-Xlint:-path']
    groovyOptions.encoding = 'utf-8'
    inputs.property('javaInstallation') {
        currentJavaInstallation.displayName
    }
}

class DefaultJavaInstallation implements LocalJavaInstallation {
    JavaVersion javaVersion
    File javaHome
    String displayName
    String name
}