forked from opprop/checker-framework-inference
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
240 lines (204 loc) · 7.26 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
/// Why doesn't this work on Travis under Java 7?
/// The same text does in Randoop's build.gradle file.
// plugins {
// /*
// * Plugin that applies Google-Java-format to the Java files in the project.
// * https://github.com/sherter/google-java-format-gradle-plugin
// */
// id 'com.github.sherter.google-java-format' version '0.6'
// }
plugins {
id 'com.github.johnrengelman.shadow' version '2.0.2'
}
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 {
assert JavaVersion.current() == JavaVersion.VERSION_1_8: "Set JAVA_HOME to JDK 8. Current version is ${JavaVersion.current()}"
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"
z3Jar = "${projectDir}/lib/com.microsoft.z3.jar"
}
println '===================================='
println ' Checker Framework Inference '
println '===================================='
println ''
println '-------------------------------'
println 'Important Environment Variables'
println '-------------------------------'
println 'JSR308 : ' + jsr308
println 'CHECKERFRAMEWORK: ' + checkerFrameworkPath
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile files("${checkerJar}")
compile 'org.plumelib:options:0.3.1'
// Serialize constraints
compile 'com.googlecode.json-simple:json-simple:1.1' // don't use version 1.1.1 as it adds a junit 4.10 dependency in eclipse
// Pretty print serialized constraints
compile 'com.google.code.gson:gson:1.7.2'
compile 'org.ow2.sat4j:org.ow2.sat4j.core:2.3.4'
compile 'org.ow2.sat4j:org.ow2.sat4j.maxsat:2.3.4'
compile files(z3Jar)
compile group: 'org.checkerframework', name: 'testlib', version: '2.5.1'
// Mocking library. Used in a couple tests
testCompile 'org.mockito:mockito-all:2.0.2-beta'
testCompile 'junit:junit:4.12'
}
sourceSets {
main {
java {
srcDirs = ['src']
}
resources {
srcDir "src"
include "**/*.astub"
}
}
test {
java {
srcDirs = ["tests"]
}
}
}
task buildZ3(type: Exec) {
description 'Build Z3 if it has already been built'
onlyIf { !(new File(z3Jar).exists()) }
workingDir './scripts'
commandLine './buildZ3'
}
test {
dependsOn(shadowJar)
systemProperties 'path.afu.scripts': "${afu}/scripts",
'path.inference.script': "${projectDir}/scripts/inference",
'use.hacks': true,
JDK_JAR: "${checkerFrameworkPath}/checker/dist/jdk8.jar"
if (project.hasProperty('emit.test.debug')) {
systemProperties += ["emit.test.debug": 'true']
}
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 {
dependsOn buildZ3
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) }
}
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'
}
}
task release(type: Zip) {
from('src') {
into('release/src')
}
from('dist') {
into('release/dist')
}
from('scripts') {
into('release/scripts')
include '*.py'
}
baseName = 'release'
}
/// 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 countHacks(type: Exec) {
commandLine "bash", "-c", "grep -r 'InferenceMain.isHackMode(' src/ | wc -l"
}