-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuild.gradle
More file actions
118 lines (102 loc) · 4.19 KB
/
Copy pathbuild.gradle
File metadata and controls
118 lines (102 loc) · 4.19 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
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
plugins {
id("java")
id("maven-publish")
}
repositories {
// Use Maven Central for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
}
configurations {
// for putting Error Prone javac in bootclasspath for running tests
errorproneJavac
}
ext.versions = [
checkerFramework: "4.2.1",
]
compileJava {
sourceCompatibility = JavaVersion.VERSION_21
}
def checkerframework_local = false // Set this variable to [true] while using local version of checker framework.
dependencies {
// This dependency is found on compile classpath of this component and consumers.
if (checkerframework_local) {
implementation(files("${CHECKERFRAMEWORK}/checker/dist/checker-qual.jar"))
implementation(files("${CHECKERFRAMEWORK}/checker/dist/checker.jar"))
}
else {
implementation("org.checkerframework:checker:${versions.checkerFramework}")
implementation("org.checkerframework:checker-qual:${versions.checkerFramework}")
}
compileOnly("com.google.errorprone:javac:9+181-r4173-1")
// Testing
testImplementation("junit:junit:4.13.2")
testImplementation("org.checkerframework:framework-test:${versions.checkerFramework}")
errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
}
tasks.withType(JavaCompile).all {
options.compilerArgs.add("-Xlint:all")
}
// Add `mavenLocal()` in `repositories`, then run `./gradlew publishToMavenLocal`
// to publish your checker to your local Maven repository.
publishing {
publications {
maven(MavenPublication) {
groupId = "org.checkerframework"
artifactId = "templatefora-checker"
version = "0.1-SNAPSHOT"
from(components.java)
}
}
}
test {
inputs.files("tests/templatefora")
if (!JavaVersion.current().java9Compatible) {
jvmArgs("-Xbootclasspath/p:${configurations.errorproneJavac.asPath}")
} else {
// A list of add-export and add-open arguments to be used when running the Checker Framework.
// Keep this list in sync with the list in the Checker Framework manual.
var compilerArgsForRunningCF = [
// These are required in Java 16+ because the --illegal-access option is set to deny
// by default. None of these packages are accessed via reflection, so the module
// only needs to be exported, but not opened.
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
// Required because the Checker Framework reflectively accesses private members in com.sun.tools.javac.comp.
"--add-opens", "jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
]
jvmArgs += compilerArgsForRunningCF
}
testLogging {
showStandardStreams = true
// Show the found unexpected diagnostics and expected diagnostics not found.
exceptionFormat = "full"
events("failed")
}
}
clean.doFirst {
delete("${rootDir}/tests/build/")
}
tasks.register("printClasspath") {
description = "Prints the runtime classpath of the checker. " +
"When typechecking, put the output of this task on either the " +
"processor path or the classpath of the project being type-checked."
doLast {
println(sourceSets.main.runtimeClasspath.asPath)
}
}
sourceSets {
main {
resources {
// ensures that any .stub files present in the same directory as
// the checker source code are copied into the distributed jar
srcDirs += ["src/main/java"]
}
}
}