-
Notifications
You must be signed in to change notification settings - Fork 348
/
build.gradle
248 lines (216 loc) · 10.1 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
plugins {
id 'java-library'
}
dependencies {
api project(':javacutil')
api project(':checker-qual')
// Node implements org.plumelib.util.UniqueId, so this dependency must be "api".
api "org.plumelib:plume-util:${plumeUtilVersion}"
// External dependencies:
// If you add an external dependency, you must shadow its packages both in the dataflow-shaded
// artifact (see shadowJar block below) and also in checker.jar (see the comment in
// ../build.gradle in the shadowJar block).
}
// Shadowing Test Sources and Dependencies
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
/**
* Creates a task with name dataflow${shadedPkgName} that creates a shaded dataflow jar. The packages will be shaded to
* "org.checkerframework.{@code shadedPkgName}" and the jar name is dataflow-${shadedPkgName}.jar.
* @param shadedPkgName
* @return
*/
def createDataflowShaded(shadedPkgName) {
tasks.create(name: "dataflow${shadedPkgName}Jar", type: ShadowJar, dependsOn: compileJava, group: 'Build') {
description "Builds dataflow-${shadedPkgName}.jar."
includeEmptyDirs = false
archivesBaseName = "dataflow-${shadedPkgName}"
// Without this line, the Maven artifact will have the classifier "all".
archiveClassifier.set('')
from shadowJar.source
configurations = shadowJar.configurations
destinationDirectory = file("${buildDir}/shadow/dataflow${shadedPkgName}")
relocate('org.checkerframework', "org.checkerframework.${shadedPkgName}") {
// Shade all Checker Framework packages, except for the dataflow qualifiers.
exclude 'org.checkerframework.dataflow.qual.*'
}
// Relocate external dependencies
relocate 'org.plume', "org.checkerframework.${shadedPkgName}.org.plume"
}
}
// Creates a new shaded dataflow artifact. To add a new one, add a new method call below, and add
// the new jar to publishing and signing blocks.
createDataflowShaded('shaded')
createDataflowShaded('nullaway')
createDataflowShaded('errorprone')
task liveVariableTest(dependsOn: [assemble, compileTestJava], group: 'Verification') {
description 'Test the live variable analysis test for dataflow framework.'
inputs.file('tests/live-variable/Expected.txt')
inputs.file('tests/live-variable/Test.java')
outputs.file('tests/live-variable/Out.txt')
outputs.file('tests/live-variable/Test.class')
delete('tests/live-variable/Out.txt')
delete('tests/live-variable/Test.class')
doLast {
javaexec {
workingDir = 'tests/live-variable'
if (!JavaVersion.current().java9Compatible) {
jvmArgs += "-Xbootclasspath/p:${configurations.javacJar.asPath}".toString()
}
else if (JavaVersion.current() > JavaVersion.VERSION_11) {
jvmArgs += [
'--add-opens', 'jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
]
}
classpath = sourceSets.test.runtimeClasspath
classpath += sourceSets.test.output
mainClass = 'livevar.LiveVariable'
}
exec {
workingDir = 'tests/live-variable'
executable 'diff'
args = ['-u', 'Expected.txt', 'Out.txt']
}
}
}
task issue3447Test(dependsOn: [assemble, compileTestJava], group: 'Verification') {
description 'Test issue 3447 test case for backward analysis.'
inputs.file('tests/issue3447/Test.java')
delete('tests/issue3447/Out.txt')
delete('tests/issue3447/Test.class')
doLast {
javaexec {
workingDir = 'tests/issue3447'
if (!JavaVersion.current().java9Compatible) {
jvmArgs += "-Xbootclasspath/p:${configurations.javacJar.asPath}".toString()
}
else if (JavaVersion.current() > JavaVersion.VERSION_11) {
jvmArgs += [
'--add-opens', 'jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
]
}
classpath = sourceSets.test.runtimeClasspath
classpath += sourceSets.test.output
mainClass = 'livevar.LiveVariable'
}
}
}
task constantPropagationTest(dependsOn: [assemble, compileTestJava], group: 'Verification') {
description 'Test the constant propagation analysis of the dataflow framework.'
inputs.file('tests/constant-propagation/Expected.txt')
inputs.file('tests/constant-propagation/Test.java')
outputs.file('tests/constant-propagation/Out.txt')
outputs.file('tests/constant-propagation/Test.class')
delete('tests/constant-propagation/Out.txt')
delete('tests/constant-propagation/Test.class')
doLast {
javaexec {
workingDir = 'tests/constant-propagation'
if (!JavaVersion.current().java9Compatible) {
jvmArgs += "-Xbootclasspath/p:${configurations.javacJar.asPath}".toString()
}
else if (JavaVersion.current() > JavaVersion.VERSION_11) {
jvmArgs += [
'--add-opens', 'jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
'--add-opens', 'jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
]
}
classpath = sourceSets.test.runtimeClasspath
classpath += sourceSets.test.output
mainClass = 'constantpropagation.ConstantPropagation'
}
exec {
workingDir = 'tests/constant-propagation'
executable 'diff'
args = ['-u', 'Expected.txt', 'Out.txt']
}
}
}
apply from: rootProject.file('gradle-mvn-push.gradle')
/** Adds information to the publication for uploading the dataflow artifacts to Maven repositories. */
final dataflowPom(publication) {
sharedPublicationConfiguration(publication)
publication.from components.java
// Information that is in all pom files is configured in checker-framework/gradle-mvn-push.gradle.
publication.pom {
name = 'Dataflow'
description = 'Dataflow is a dataflow framework based on the javac compiler.'
licenses {
license {
name = 'GNU General Public License, version 2 (GPL2), with the classpath exception'
url = 'http://www.gnu.org/software/classpath/license.html'
distribution = 'repo'
}
}
}
}
/**
* Adds information to the publication for uploading the dataflow-${shadedPkgName} artifacts to Maven repositories.
* @param shadedPkgName the name of the shaded package to use; also used as part of the artifact name: "dataflow-${shadePkgName}"
*/
final dataflowShadedPom(MavenPublication publication, String shadedPkgName) {
sharedPublicationConfiguration(publication)
publication.artifactId = "dataflow-${shadedPkgName}"
publication.pom {
name = "Dataflow (${shadedPkgName})"
description = "dataflow-${shadedPkgName} is a dataflow framework based on the javac compiler.\n" +
'\n' +
'It differs from the org.checkerframework:dataflow artifact in two ways.\n' +
"First, the packages in this artifact have been renamed to org.checkerframework.${shadedPkgName}.*.\n" +
'Second, unlike the dataflow artifact, this artifact contains the dependencies it requires.'
licenses {
license {
name = 'GNU General Public License, version 2 (GPL2), with the classpath exception'
url = 'http://www.gnu.org/software/classpath/license.html'
distribution = 'repo'
}
}
}
}
publishing {
publications {
dataflow(MavenPublication) {
dataflowPom it
}
dataflowShaded(MavenPublication) {
dataflowShadedPom(it, 'shaded')
artifact getTasksByName('dataflowshadedJar',false).iterator().next()
artifact sourcesJar
artifact javadocJar
}
dataflowShadednullaway(MavenPublication) {
dataflowShadedPom(it, 'nullaway')
artifact getTasksByName('dataflownullawayJar',false).iterator().next()
artifact sourcesJar
artifact javadocJar
}
dataflowShadederrorprone(MavenPublication) {
dataflowShadedPom(it, 'errorprone')
artifact getTasksByName('dataflowerrorproneJar',false).iterator().next()
artifact sourcesJar
artifact javadocJar
}
}
}
signing {
sign publishing.publications.dataflow
sign publishing.publications.dataflowShaded
sign publishing.publications.dataflowShadednullaway
sign publishing.publications.dataflowShadederrorprone
}