-
Notifications
You must be signed in to change notification settings - Fork 33
/
build.gradle
263 lines (219 loc) · 7.99 KB
/
build.gradle
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
plugins {
id 'com.github.johnrengelman.shadow' version '6.1.0'
}
apply plugin: 'java'
// Note: For this setup to work you must follow the instructions outlined in the
// checker manual Section 25.3 "Building from Source"
// http://types.cs.washington.edu/checker-framework/current/checkers-manual.html#build-source
ext {
jsr308 = System.getenv('JSR308') ?: file(new File("..")).absolutePath
checkerFrameworkPath = System.getenv('CHECKERFRAMEWORK') ?: "${jsr308}/checker-framework"
checkerJar = "${checkerFrameworkPath}/checker/dist/checker.jar"
afu = "${jsr308}/annotation-tools/annotation-file-utilities"
// On a Java 8 JVM, use error-prone javac and source/target 8.
// On a Java 9+ JVM, use the host javac, default source/target, and required module flags.
isJava8 = JavaVersion.current() == JavaVersion.VERSION_1_8
errorproneJavacVersion = '9+181-r4173-1'
}
println '===================================='
println ' Checker Framework Inference '
println '===================================='
println ''
println '-------------------------------'
println 'Important Environment Variables'
println '-------------------------------'
println 'CHECKERFRAMEWORK: ' + checkerFrameworkPath
repositories {
jcenter()
mavenCentral()
}
configurations {
javacJar
}
dependencies {
if (isJava8) {
javacJar group: 'com.google.errorprone', name: 'javac', version: "$errorproneJavacVersion"
}
compile files("${checkerJar}")
compile group: 'com.google.errorprone', name: 'javac', version: "$errorproneJavacVersion"
compile 'org.plumelib:options:1.0.4'
implementation 'org.plumelib:plume-util:1.1.7'
// Serialize constraints
compile 'com.googlecode.json-simple:json-simple:1.1.1'
// Pretty print serialized constraints
compile 'com.google.code.gson:gson:2.8.6'
compile 'org.ow2.sat4j:org.ow2.sat4j.core:2.3.5'
compile 'org.ow2.sat4j:org.ow2.sat4j.maxsat:2.3.5'
testCompile fileTree(dir: "${checkerFrameworkPath}/framework-test/build/libs", include: "framework-test-*.jar")
// Mocking library. Used in a couple tests
testCompile 'org.mockito:mockito-all:2.0.2-beta'
testCompile 'junit:junit:4.13.1'
}
sourceSets {
main {
java {
srcDirs = ["src"]
}
resources {
srcDir "src"
include "**/*.astub"
}
}
test {
java {
srcDirs = ["tests"]
}
}
}
test {
dependsOn(shadowJar)
dependsOn('dist')
systemProperties 'path.afu.scripts': "${afu}/scripts",
'use.hacks': true
systemProperties += [JDK_JAR: "${checkerFrameworkPath}/checker/dist/jdk8.jar"]
if (project.hasProperty('emit.test.debug')) {
systemProperties += ["emit.test.debug": 'true']
}
if (isJava8) {
jvmArgs += ["-Xbootclasspath/p:${configurations.javacJar.asPath}"]
}
testLogging {
// Always run the tests
outputs.upToDateWhen { false }
// The following prints out each time a test is passed.
// events "passed", "skipped", "failed", "standardOut", "standardError"
// Show the found unexpected diagnostics and expected diagnostics not found.
exceptionFormat "full"
}
// After each test, print a summary.
afterSuite { desc, result ->
if (desc.getClassName() != null) {
long mils = result.getEndTime() - result.getStartTime()
double seconds = mils / 1000.0
println "Testsuite: ${desc.getClassName()}\n" +
"Tests run: ${result.testCount}, " +
"Failures: ${result.failedTestCount}, " +
"Skipped: ${result.skippedTestCount}, " +
"Time elapsed: ${seconds} sec\n"
}
}
}
compileJava {
options.compilerArgs = [
'-implicit:class',
'-Awarns',
'-Xmaxwarns', '10000',
// Can't use this because JSON library contains raw types:
// '-Xlint:unchecked',
'-Xlint:deprecation',
'-Werror',
]
}
// Exclude parts of the build directory that don't include classes from being packaged in
// the jar file.
// IMPORTANT: If "libs" is packaged in the JAR file you end up with an infinitely
// recursive jar task that will fill up your hard drive (eventually)
jar {
description = 'Makes a jar with ONLY the classes compiled for checker ' +
'framework inference and NONE of its dependencies'
archiveName = "checker-framework-inference.jar"
manifest.attributes("Main-Class": "checkers.inference.InferenceLauncher")
exclude("dependency-cache", "libs", "tmp")
}
shadowJar {
description 'Creates the "fat" checker.jar in dist'
destinationDir = file("${projectDir}/dist")
archiveName = "checker-framework-inference.jar"
}
task dependenciesJar(type: Jar) {
description 'Create a jar file with all the dependencies.'
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
configurations.testCompile.collect { it.isDirectory() ? it : zipTree(it) }
}
archiveName 'dependencies.jar'
destinationDir file("${projectDir}/dist/")
}
task dist(dependsOn: shadowJar, type: Copy) {
description = "If your Checker Framework project is fully built, this task " +
"will build checker-framework-inference.jar, copy all the relevant runtime jars into " +
"the dist directory."
from files(
"${checkerFrameworkPath}/checker/dist/jdk8.jar",
"${checkerFrameworkPath}/checker/dist/checker.jar",
"${checkerFrameworkPath}/checker/dist/checker-qual.jar",
"${checkerFrameworkPath}/checker/dist/javac.jar",
)
into file('dist')
}
tasks.clean {
delete += "build/libs/checker-framework-inference.zip"
delete += "jdk8.jar"
delete += "javac.jar"
delete += fileTree('dist') {
include '**/*.jar'
}
delete += "testdata/tmp"
}
task release(type: Zip) {
from('src') {
into('release/src')
}
from('dist') {
into('release/dist')
}
from('scripts') {
into('release/scripts')
include '*.py'
}
baseName = 'release'
}
task testCheckerInferenceScript(type: Exec, dependsOn: dist) {
description 'Basic sanity check of scripts/inference'
executable './scripts/inference'
args = ['--mode', 'TYPECHECK',
'--checker', 'ostrusted.OsTrustedChecker',
'--solver', 'checkers.inference.solver.PropagationSolver',
'testdata/ostrusted/Test.java']
}
task testCheckerInferenceDevScript(type: Exec, dependsOn: [dist, dependenciesJar]) {
description 'Basic sanity check of scripts/inference-dev'
executable './scripts/inference-dev'
args = ['--mode', 'INFER',
'--checker', 'interning.InterningChecker',
'--solver', 'checkers.inference.solver.MaxSat2TypeSolver',
'--hacks=true',
'testdata/interning/MapAssignment.java']
}
/// Commented out because plugins section is commented out
// /* Configuration for formatting */
// googleJavaFormat {
// // toolVersion '1.3'
// options style: 'AOSP'
// }
// tasks.googleJavaFormat {
// group 'Formatting'
// description = "Reformat Java source code with Google-Java-format"
// exclude 'testing'
// exclude 'testinputs'
// }
// tasks.verifyGoogleJavaFormat {
// group 'Formatting'
// description = "Check Java source code is in Google-Java-format"
// exclude 'testing'
// exclude 'testinputs'
// }
task etags {
doLast {
def sources = (sourceSets.main.java).getFiles().collect({ src -> src.getPath() }).sort()
def sourcesStr = sources.inject(null, { acc, source -> acc ? acc + " " + source : source })
def proc = "etags ${sourcesStr} ".execute()
proc.in.eachLine { line -> println line }
proc.err.eachLine { line -> println 'ERROR: ' + line }
proc.waitFor()
}
}
task tags(dependsOn: etags)
task countHacks(type: Exec) {
commandLine "bash", "-c", "grep -r 'InferenceMain.isHackMode(' src/ | wc -l"
}