-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheckerframework.gradle
More file actions
45 lines (41 loc) · 1.94 KB
/
checkerframework.gradle
File metadata and controls
45 lines (41 loc) · 1.94 KB
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
///////////////////////////////////////////////////////////////////////////
/// Checker Framework pluggable type-checking
///
repositories {
mavenCentral()
}
configurations {
checkerFrameworkCheckerJar {
description = 'the Checker Framework, including the Type Annotations compiler'
}
checkerFrameworkAnnotatedJDK {
description = 'a copy of JDK classes with Checker Framework type qualifers inserted'
}
}
// Checker Framework from Maven Central
dependencies {
ext.checkerFrameworkVersion = '2.4.0'
checkerFrameworkAnnotatedJDK "org.checkerframework:jdk8:${checkerFrameworkVersion}"
checkerFrameworkCheckerJar "org.checkerframework:checker:${checkerFrameworkVersion}"
/* NOTE: we must NOT use compile or api, because then the checker-qual jar would end up in the android-classpath:
* ..checker-qual-2.4.0.jar: Error: Invalid package reference in library; not included in Android: java.awt.image.
* Referenced from org.checkerframework.checker.signedness.SignednessUtil. [InvalidPackage]
*/
implementation "org.checkerframework:checker-qual:${checkerFrameworkVersion}"
}
// To typecheck only the current project's main source set (in a multi-project build)
compileJava {
doFirst {
// note: we must explicitly use .toString(), otherwise we get this error (gradle 4.6):
// org.codehaus.groovy.runtime.GStringImpl cannot be cast to java.lang.String
options.compilerArgs = [
'-processorpath', "${configurations.checkerFrameworkCheckerJar.asPath}".toString(),
'-processor', 'org.checkerframework.checker.nullness.NullnessChecker',
'-Xmaxerrs', '10000',
'-Xmaxwarns', '10000',
// '-Awarns', // turn Checker Framework errors into warnings
'-AcheckPurityAnnotations',
"-Xbootclasspath/p:${configurations.checkerFrameworkAnnotatedJDK.asPath}".toString()
]
}
}