-
Notifications
You must be signed in to change notification settings - Fork 578
/
build.gradle
284 lines (245 loc) · 8.29 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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
sourceSets {
main {
java {
srcDirs = ['src/java', 'src/gui', 'src/antTask']
}
resources {
/*
* Becuase why put everything in a single folder when you can split it
* and mix it with other files you don't actually need together
*/
srcDirs = ['src/xsl', 'etc', 'src/java', 'src/gui']
include '*.xsd'
include 'bugrank.txt'
include 'findbugs.xml'
include 'messages*.xml'
include '**/*.properties'
exclude 'doc.properties'
exclude 'script.properties'
include '*.xsl'
include '**/*.db'
include '**/*.html'
include '**/*.png'
}
}
test {
java {
srcDirs = ['src/junit']
}
}
}
configurations {
annotations
}
dependencies {
compile 'org.apache.bcel:bcel:6.0'
compile 'org.ow2.asm:asm-debug-all:6.0_ALPHA'
// TODO : Some of these can be extracted to actual dependencies
compile fileTree(dir: 'lib', include: '*.jar')
}
tasks.withType(Jar).all {
includeEmptyDirs = false
// FIXME: this is ugly, but is what ant is currently doing... our own jars are included as dependencies :S
//destinationDir = file("$projectDir/lib")
}
// Manually define what goes into the default jar, since it's not only main sourceset
jar {
from sourceSets.main.output
baseName 'spotbugs' // Needed until we rename the directory
manifest {
attributes 'Main-Class': 'edu.umd.cs.findbugs.LaunchAppropriateUI',
'Bundle-Version': project.version,
'Class-Path': 'bcel.jar dom4j-1.6.1.jar jaxen-1.1.6.jar asm-debug-all-6.0_ALPHA jsr305.jar jFormatString.jar commons-lang-2.6.jar'
}
}
// Make the anttask jar as part of the build process
task anttaskJar(type:Jar) {
from sourceSets.main.output
include '**/anttask/*'
baseName 'spotbugs-ant'
}
// Build spotbugs annotations jar
task spotbugsAnnotationsJar(type:Jar) {
from sourceSets.main.output
include '**/annotations/*'
baseName 'spotbugs-annotations'
manifest {
attributes 'Bundle-Name': 'SpotbugsInternalAnnotations',
'Bundle-SymbolicName': 'spotbugsInternalAnnotations',
'Bundle-Version': project.version,
'Export-Package': 'edu.umd.cs.findbugs.annotations',
'Bundle-RequiredExecutionEnvironment': 'J2SE-1.5'
}
}
// TODO : This jar should probably be dropped. Just use the one above, and add transitive dependencies
// Build ALL annotations jar
task annotationsJar(type:Jar) {
from(sourceSets.main.output) {
include '**/annotations/*'
}
// TODO : These includes source java files.. exclude them and put them in a separate sources jar?
from zipTree("$projectDir/lib/jcip-annotations.jar").matching {
exclude 'META-INF/**'
exclude '**/*.html'
}
from zipTree("$projectDir/lib/jsr305.jar").matching { // TODO : to be dropped
exclude 'META-INF/**'
exclude '**/*.html'
}
baseName 'annotations'
manifest {
attributes 'Bundle-ManifestVersion': 2,
'Bundle-Name': 'SpotbugsAnnotations',
'Bundle-SymbolicName': 'spotbugsAnnotations',
'Bundle-Version': project.version,
'Export-Package': 'edu.umd.cs.findbugs.annotations, javax.annotation, ' +
'javax.annotation.concurrent, javax.annotation.meta, net.jcip.annotations',
'Bundle-RequiredExecutionEnvironment': 'J2SE-1.5'
}
}
tasks['jar'].dependsOn 'anttaskJar', 'spotbugsAnnotationsJar', 'annotationsJar'
// Populate bin folder with scripts
task scripts(type:Copy) {
// Take the properties into account for up-to-date checking
inputs.file "$projectDir/etc/script.properties"
def props = new Properties()
doFirst {
props.load(new FileInputStream("$projectDir/etc/script.properties"))
filesNotMatching('**/*.ico') {
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [
'GET_FBHOME': props.getProperty('script.get.fbhome'),
'SET_DEFAULT_JAVA': props.getProperty('script.set.default.java'),
'WRAP_JAVA': props.getProperty('script.wrap.java'),
'WRAP_JAR': props.getProperty('script.wrap.jar'),
'DEFINE_ESCAPE_ARG': props.getProperty('script.define.escape_arg')])
fileMode 0755
}
}
from 'src/scripts/standard'
from 'src/scripts/windows'
from('src/scripts/deprecated') {
into 'deprecated'
}
from('src/scripts/experimental') {
into 'experimental'
}
destinationDir file('bin')
duplicatesStrategy DuplicatesStrategy.INCLUDE
}
apply from: "$rootDir/gradle/checkstyle.gradle"
apply from: "$rootDir/gradle/javadoc.gradle"
// annotations javadoc
task annotationJavadoc(type:Javadoc) {
options.with {
memberLevel = JavadocMemberLevel.PUBLIC
docTitle = 'SpotBugs Annotation Documentation'
}
classpath = sourceSets.main.compileClasspath
source sourceSets.main.java.srcDirs
include 'edu/umd/cs/findbugs/annotations/*'
destinationDir = file("${project.docsDir}/annotations-javadoc")
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier 'javadoc'
baseName 'spotbugs' // TODO : This is undeeded once we change the dir / project name
from javadoc.destinationDir
}
task annotationJavadocJar(type: Jar, dependsOn: annotationJavadoc) {
classifier 'javadoc'
baseName 'spotbugs-annotations'
from annotationJavadoc.destinationDir
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
baseName 'spotbugs' // TODO : This is undeeded once we change the dir / project name
from sourceSets.main.allSource
}
task annotationSourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
baseName 'spotbugs-annotations'
from sourceSets.main.allSource
include '**/annotations/*'
}
artifacts {
archives javadocJar
archives annotationJavadocJar
archives sourcesJar
archives annotationSourcesJar
annotations annotationsJar
}
apply plugin: 'distribution'
distributions {
main {
baseName = 'spotbugs' // TODO : This is undeeded once we change the dir / project name
contents {
from(scripts) {
into 'bin'
}
from 'README.txt'
from 'licenses'
from('lib') {
into 'lib'
// TODO : These exclusions can be removed when we move dependencies from lib to dependency management
exclude 'AppleJavaExtensions.jar'
exclude 'junit.jar'
include '**/*.jar'
}
from([jar, spotbugsAnnotationsJar, anttaskJar]) {
into 'lib'
rename "(.*)-${project.version}.jar", '$1.jar'
}
from('src/xsl') {
into 'src/xsl'
include '**/*.xsl'
}
}
}
}
distTar.compression = Compression.GZIP
tasks['assemble'].dependsOn tasks['assembleDist']
task distSrcZip(type:Exec) {
commandLine 'git', 'archive', '-o', "${buildDir}/distributions/spotbugs-${project.version}-source.zip",
'--prefix', "spotbugs-${project.version}/", 'HEAD'
}
tasks['assembleDist'].finalizedBy distSrcZip
test {
dependsOn ':findbugsTestCases:build'
}
task unzipDist(type:Copy, dependsOn:distZip) {
from zipTree(distZip.outputs.files.singleFile)
into file("$buildDir/smoketest/")
// Remove prefix
eachFile { details ->
details.path = details.path - "spotbugs-${project.version}"
}
}
// TODO : actually check the output beyond it not blowing up in pieces?
task smokeTest {
dependsOn unzipDist
doLast {
ant.taskdef(name:'spotbugs', classname:'edu.umd.cs.findbugs.anttask.FindBugsTask', classpath:anttaskJar.outputs.files.asPath)
ant.spotbugs(home:"$buildDir/smoketest/", output:'xml:withMessages',
jvmargs:'-ea -Xmx1200m',
excludeFilter:'findbugsExclude.xml',
projectName:'spotbugs',
maxRank:'20',
timeout:'1800000',
outputFile:"${buildDir}/smoketest/findbugscheckAll.xml") {
sourcePath(path:'src/java:src/gui:src/junit:src/tools:src/antTask')
'class'(location:project.tasks['compileJava'].destinationDir)
auxClasspath(path:project.fileTree(dir:'lib', include:'**/*.jar').asPath)
}
}
}
// TODO : jsr305.jar (really?)
// TODO : generatemanual (we should decide what to do with the manual)
// TODO : generatepdfmanual
// TODO : bugdesc
// Smoke testing
// TODO : plugincheck_fbcontrib
// TODO : spotbugsTestCases (already analyzed by unit tests... not particularly useful, is it?)
// Integration testing
// TODO : validatesamplehtmloutput (really?)
// TODO : validatesamplexmloutput
// XML validation
// TODO : validate