File: build.gradle

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,840 kB
  • sloc: java: 145,910; xml: 839; sh: 518; makefile: 401; perl: 26
file content (174 lines) | stat: -rw-r--r-- 6,225 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
sourceSets {
    main {
        resources {
            // Stub files, message.properties, etc.
            srcDirs = ['src/main/java']
            exclude '**/*.java'
        }
    }
    testannotations
    test {
        java {
            // Tests that fail by design.
            exclude 'tests/SubtypingStringPatternsPartialTest.java'
        }
    }
}

dependencies {
    implementation project(':dataflow')
    implementation project(':javacutil')
    implementation files("${stubparserJar}")
    implementation files("${afuJar}")
    implementation project(':checker-qual')
    // As of 2019/12/16, the version of reflection-util in the Annotation
    // File Utilities takes priority over this version, in the fat jar
    // file. :-( So update it and re-build it locally when updating this.
    implementation 'org.plumelib:reflection-util:0.2.2'

    testImplementation group: 'junit', name: 'junit', version: '4.13'
    testImplementation project(':framework-test')
    testImplementation sourceSets.testannotations.output
}

task checkDependencies() {
    doLast {
        if (!file(afuJar).exists()) {
            if (!file(stubparserJar).exists()) {
                throw new GradleException("${afuJar} and ${stubparserJar} do not exist. Try running './gradlew cloneAndBuildDependencies'")
            }
            throw new GradleException("${afuJar} does not exist. Try running './gradlew cloneAndBuildDependencies'")
        }
        if (!file(stubparserJar).exists()) {
            throw new GradleException("${stubparserJar} does not exist. Try running './gradlew cloneAndBuildDependencies'")
        }
    }
}

compileJava.dependsOn(checkDependencies)

task allSourcesJar(type: Jar) {
    description 'Creates a sources jar that includes sources for all Checker Framework classes in framework.jar'
    destinationDirectory = file("${projectDir}/dist")
    archiveFileName = "framework-source.jar"
    from (project(':framework').sourceSets.main.java,
            project(':dataflow').sourceSets.main.allJava,
            project(':javacutil').sourceSets.main.allJava)
}

task allJavadocJar(type: Jar) {
    description 'Creates javadoc jar include Javadoc for all of the framework'
    dependsOn rootProject.tasks.allJavadoc
    destinationDirectory = file("${projectDir}/dist")
    archiveFileName = "framework-javadoc.jar"
    from (project(':framework').tasks.javadoc.destinationDir,
            project(':dataflow').tasks.javadoc.destinationDir,
            project(':javacutil').tasks.javadoc.destinationDir)
}

shadowJar {
    description 'Creates the "fat" framework.jar in dist'
    destinationDirectory = file("${projectDir}/dist")
    archiveFileName = "framework.jar"
    manifest {
        attributes('Automatic-Module-Name': "org.checkerframework.framework")
    }
}

createCheckTypeTask(project.name, 'org.checkerframework.checker.compilermsgs.CompilerMessagesChecker', "CompilerMessages")
checkCompilerMessages {
    options.compilerArgs += [
            '-Apropfiles=' + sourceSets.main.resources.filter { file -> file.name.equals('messages.properties') }.asPath
    ]
}

task testWPI(type: Test) {
    doFirst {
        delete("tests/whole-program-inference/annotated")
    }
    outputs.upToDateWhen { false }
    include '**/WholeProgramInferenceTest.class'
    testLogging {
        // Always run the tests
        outputs.upToDateWhen { false }

        // Show the found unexpected diagnostics and expected diagnostics not found.
        exceptionFormat "full"
        events "passed", "skipped", "failed"
    }
}

task testWPIValidate(type: Test) {
    outputs.upToDateWhen { false }
    include '**/WholeProgramInferenceValidationTest.class'
    testLogging {
        // Always run the tests
        outputs.upToDateWhen { false }

        // Show the found unexpected diagnostics and expected diagnostics not found.
        exceptionFormat "full"
        events "passed", "skipped", "failed"
    }
}

task wholeProgramInferenceTests(dependsOn: 'shadowJar', group: 'Verification') {
    description 'Run tests for whole-program inference using .jaif files'
    dependsOn(compileTestJava)
    dependsOn(testWPI)
    outputs.upToDateWhen { false }

    doLast {
        // Copying all test files to another directory, removing all expected errors that should not
        // occur after inserting inferred annotations from .jaif files.
        copy {
            from files('tests/whole-program-inference/non-annotated')
            into file('tests/whole-program-inference/annotated')
            filter { String line ->
                line.contains('// :: error:') ? null : line
            }
        }
        // The only file for which expected errors are maintained is ExpectedErrors.java, so we copy it over
        delete('tests/whole-program-inference/annotated/ExpectedErrors.java')
        copy {
            from file('tests/whole-program-inference/non-annotated/ExpectedErrors.java')
            into file('tests/whole-program-inference/annotated')
        }

        // Inserting annotations from .jaif files in-place.
        List<File> jaifs = fileTree("${buildDir}/whole-program-inference/").matching {
            include '*.jaif'
        }.asList()
        List<File> javas = fileTree("tests/whole-program-inference/annotated/").matching {
            include '*.java'
        }.asList()
        exec {
            executable "${afu}/scripts/insert-annotations-to-source"
            args = ['-i']
            for (File jaif : jaifs) {
                args += [jaif.toString()]
            }
            for (File javaFile : javas) {
                args += [javaFile.toString()]
            }
        }
    }
    finalizedBy(testWPIValidate)
}

task loaderTests(dependsOn: 'shadowJar', group: 'Verification') {
    description 'Run tests for the annotation class loader'
    dependsOn(compileTestJava)
    // TODO: this dependency on checker is a bit ugly.
    dependsOn project(':checker-qual').tasks.jar
    dependsOn project(':checker').tasks.assemble
    doLast {
        exec {
            executable 'make'
            args = ['-C', "tests/annotationclassloader/", "all"]
        }
    }
}

clean {
    delete("tests/whole-program-inference/annotated")
}