forked from groovy/groovy-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
456 lines (413 loc) · 14.8 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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
apply from: 'gradle/filter.gradle'
apply from: "gradle/indy.gradle"
// TODO use antlr plugin
//apply plugin: 'antlr'
allprojects {
apply plugin: 'java'
buildDir = 'target'
sourceCompatibility = 1.5
targetCompatibility = 1.5
group = 'org.codehaus.groovy'
version = groovyVersion
repositories {
mavenCentral()
}
apply plugin: 'checkstyle'
apply plugin: 'groovy'
apply plugin: 'codenarc'
apply from: "${rootProject.projectDir}/gradle/groovydoc.gradle"
apply from: "${rootProject.projectDir}/gradle/indy.gradle"
// don't fail build on CodeNarc tasks
tasks.withType(CodeNarc) {
ignoreFailures = true
configFile = file("$rootProject.projectDir/config/codenarc/codenarc.groovy")
}
tasks.withType(Checkstyle) {
ignoreFailures = true
configFile = file("$rootProject.projectDir/config/checkstyle/checkstyle.xml")
}
if (useIndy()) {
def indyGroovy = {
options.useAnt = true
// todo: when Gradle includes support for "indy" option, replace this
// with groovyOptions.indy = true
groovyOptions.metaClass.optionMap = {
['indy':true,
memoryMaximumSize:'384m',
fork:true,
includeJavaRuntime:false,
verbose:false,
encoding:'UTF-8',
failonerror:true,
stacktrace:false,
listfiles:false]
}
groovyOptions.useAnt = true
sourceCompatibility = 1.7
targetCompatibility = 1.7
groovyClasspath = files(
rootProject.compileJava.destinationDir,
rootProject.compileJava.classpath,
{ project(':groovy-docgenerator').compileJava.destinationDir },
{ project(':groovy-groovydoc').compileJava.destinationDir },
{ project(':groovy-ant').compileJava.destinationDir },
{ project(':groovy-templates').compileJava.destinationDir },
)
}
// add tasks to compile the invokedynamic version
compileGroovy indyGroovy.clone()
compileTestGroovy indyGroovy.clone()
compileJava.sourceCompatibility = 1.7
compileJava.targetCompatibility = 1.7
jar {
classifier = 'indy'
}
}
}
// todo: use the conventional "resources" directory for classpath resources
task(copyResources, type: Copy) {
destinationDir = file("$buildDir/classes")
// text files requiring filtering
into("main") {
from('src/main')
include('**/*.txt', '**/*.xml', '**/*.properties', '**/*.html')
filter(rootProject.propertiesFilter, org.apache.tools.ant.filters.ReplaceTokens)
}
// other resources
into("main") {
from 'src/main'
include('**/*.png', '**/*.gif', '**/*.ico', '**/*.css')
}
}
compileJava.dependsOn(copyResources)
task(copyTestResources, type: Copy)
.from('src/test')
.into("$buildDir/classes/test")
.include('**/*.txt', '**/*.xml', '**/*.properties', '**/*.png', '**/*.html', '**/*.gif', '**/*.ico', '**/*.css')
compileTestJava.dependsOn(copyTestResources)
task sourceJar(type: Jar) {
classifier = 'sources'
from 'src/main'
}
subprojects {
task sourceJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
}
repositories {
// todo Some repos are needed only for some configs. Declare them just for the configuration once Gradle allows this.
// mavenCentral() // default, tools
maven { url "http://www.aQute.biz/repo" } // tools
maven { url "http://repository.jboss.org/maven2" } // examples, tools
}
// todo do we need compile and runtime scope for examples?
configurations {
compilerCompile
tools
examplesCompile.extendsFrom compile
examplesRuntime.extendsFrom examplesCompile
antlr
}
dependencies {
compilerCompile "antlr:antlr:2.7.7"
compilerCompile "org.ow2.asm:asm:4.0"
compilerCompile "org.ow2.asm:asm-analysis:4.0"
compilerCompile "org.ow2.asm:asm-commons:4.0"
compilerCompile "org.ow2.asm:asm-tree:4.0"
compilerCompile "org.ow2.asm:asm-util:4.0"
compilerCompile "commons-cli:commons-cli:1.2"
compilerCompile "org.apache.ant:ant:1.8.4"
compilerCompile("com.thoughtworks.xstream:xstream:1.4.2") {
exclude(group: 'xpp3', module: 'xpp3_min')
exclude(group: 'junit', module: 'junit')
exclude(group: 'jmock', module: 'jmock')
}
compilerCompile("jline:jline:1.0") {
exclude(group: 'junit', module: 'junit')
}
compilerCompile "org.fusesource.jansi:jansi:1.6"
compilerCompile("org.apache.ivy:ivy:2.3.0") {
transitive = false
}
compilerCompile files("$buildDir/classes/compiler")
groovy files("$buildDir/classes/compiler")
groovy "antlr:antlr:2.7.7"
groovy "org.ow2.asm:asm:4.0"
groovy "org.ow2.asm:asm-analysis:4.0"
groovy "org.ow2.asm:asm-commons:4.0"
groovy "org.ow2.asm:asm-tree:4.0"
groovy "org.ow2.asm:asm-util:4.0"
compile "commons-cli:commons-cli:1.2"
compile("com.thoughtworks.xstream:xstream:1.4.2") {
exclude(group: 'xpp3', module: 'xpp3_min')
exclude(group: 'junit', module: 'junit')
exclude(group: 'jmock', module: 'jmock')
}
compile("jline:jline:1.0") {
exclude(group: 'junit', module: 'junit')
}
compile "org.fusesource.jansi:jansi:1.6"
compile("org.apache.ivy:ivy:2.3.0") {
transitive = false
}
runtime "org.codehaus.gpars:gpars:1.0.0"
testCompile "jmock:jmock:1.2.0"
testCompile "jmock:jmock-cglib:1.2.0"
testCompile "xmlunit:xmlunit:1.3"
testCompile "ch.qos.logback:logback-classic:0.9.21"
testCompile "log4j:log4j:1.2.16"
testCompile "org.slf4j:jcl-over-slf4j:1.6.0"
testCompile "com.thoughtworks.qdox:qdox:1.12.1"
tools "com.googlecode.jarjar:jarjar:1.3"
tools("checkstyle:checkstyle:4.4") {
exclude(module: 'junit')
}
tools "redhill:simian:2.2.4"
tools("net.sourceforge.cobertura:cobertura:1.9.4.1") {
exclude(module: 'asm')
exclude(module: 'asm')
exclude(module: 'ant')
}
tools "org.ow2.asm:asm-all:4.0"
tools "com.thoughtworks.qdox:qdox:1.12.1"
tools "biz.aQute:bnd:0.0.401"
examplesCompile "lucene:lucene:1.4.3"
examplesCompile "org.eclipse:osgi:3.5.0.v20090520"
examplesRuntime("commons-httpclient:commons-httpclient:3.1") {
exclude(module: 'junit')
exclude(module: 'commons-logging')
exclude(module: 'commons-codec')
}
examplesRuntime("openejb:openejb-loader:1.0") {
exclude(module: 'log4j')
exclude(module: 'openejb-core')
exclude(module: 'geronimo-jta_1.0.1B_spec')
exclude(module: 'geronimo-servlet_2.4_spec')
exclude(module: 'geronimo-ejb_2.1_spec')
exclude(module: 'geronimo-j2ee-connector_1.5_spec')
}
// TODO use antlr plugin
// antlr "antlr:antlr:2.7.7"
antlr "org.apache.ant:ant-antlr:1.8.4"
// TODO remove once M12N refactoring finished
testCompile project(':groovy-ant')
testCompile project(':groovy-test')
}
ext.generatedDirectory = "${buildDir}/generated-sources"
sourceSets {
compiler {
// This sourceSet corresponds to the minimal "bootstrap" Groovy compiler
// which will be used by the build itself to compile the groovy files
java {
srcDirs = [
"src/main",
"subprojects/groovy-ant/src/main",
"subprojects/groovy-groovydoc/src/main",
"subprojects/groovy-templates/src/main",
"subprojects/groovy-xml/src/main",
"subprojects/groovy-jmx/src/main",
"$generatedDirectory/src/main"
]
if (!useIndy()) {
exclude '**/indy/*'
exclude '**/v7/*'
exclude '**/vm7/*'
}
}
}
main {
java {
srcDirs = [
"src/main",
"$generatedDirectory/src/main"
]
fileTree("src/main/groovy/ui").matching {
exclude 'GroovyMain.java', 'GroovySocketServer.java'
}.visit {details ->
exclude "groovy/ui/$details.path"
}
if (!useIndy()) {
exclude '**/indy/*'
exclude '**/v7/*'
exclude '**/vm7/*'
}
}
groovy {
srcDirs = [
"src/main",
"$generatedDirectory/src/main"
]
if (!useIndy()) {
exclude '**/indy/*'
exclude '**/v7/*'
exclude '**/vm7/*'
}
}
resources {
srcDirs = ["src/main", "src/tools", "src/resources"]
include "META-INF/services/*", "META-INF/groovy-release-info.properties",
"groovy/grape/*.xml", "groovy/ui/*.properties", "groovy/ui/**/*.png",
"groovy/inspect/swingui/AstBrowserProperties.groovy",
"org/codehaus/groovy/tools/shell/**/*.properties",
"org/codehaus/groovy/tools/shell/**/*.xml",
"org/codehaus/groovy/tools/groovydoc/gstringTemplates/**/*.*",
"org/codehaus/groovy/tools/groovy.ico"
}
}
test {
groovy {
srcDirs = [
"src/test",
]
if (isJava15()) {
exclude "groovy/**/vm6/*Test.groovy"
exclude "org/codehaus/groovy/**/vm6/*Test.groovy"
}
}
resources {
srcDirs = ["src/test-resources"]
}
output.classesDir = "$buildDir/test-classes" as File
}
tools {
groovy {
srcDirs = ["src/tools"]
}
resources {
srcDirs = ["src/tools"]
}
compileClasspath = configurations.tools + sourceSets.main.runtimeClasspath
runtimeClasspath = output + compileClasspath
output.classesDir = "$buildDir/tools-classes" as File
}
examples {
groovy {
srcDirs = ["src/examples"]
}
resources {
srcDirs = ["src/examples"]
}
compileClasspath = configurations.examplesRuntime + sourceSets.main.output
output.classesDir = "$buildDir/examples-classes" as File
}
}
// remove this from config once GRADLE-854 is fixed.
processResources.doLast {
copy {
from("src/main") {
include "groovy/inspect/swingui/AstBrowserProperties.groovy",
"org/codehaus/groovy/tools/groovydoc/gstringTemplates/GroovyDocTemplateInfo.java"
}
into sourceSets.main.output.classesDir
}
}
task ensureGrammars {
description = "Ensure all the Antlr generated files are up to date."
ext.antlrDirectory = "$projectDir/src/main/org/codehaus/groovy/antlr"
ext.groovyParserDirectory = "$ext.antlrDirectory/parser"
ext.javaParserDirectory = "$ext.antlrDirectory/java"
ext.genPath = "$generatedDirectory/src/main/org/codehaus/groovy/antlr"
ext.groovyOutDir = "$ext.genPath/parser"
ext.javaOutDir = "$ext.genPath/java"
inputs.dir(antlrDirectory)
outputs.dir(groovyOutDir)
outputs.dir(javaOutDir)
doFirst {
new File(groovyOutDir).mkdirs()
new File(javaOutDir).mkdirs()
ant {
taskdef(name: 'antlr',
classname: 'org.apache.tools.ant.taskdefs.optional.ANTLR',
classpath: configurations.antlr.asPath)
mkdir dir: ext.groovyParserDirectory
antlr(target: "$ext.antlrDirectory/groovy.g", outputdirectory: ext.groovyOutDir) {
classpath path: configurations.compile.asPath
}
antlr(target: "$ext.javaParserDirectory/java.g", outputdirectory: ext.javaOutDir) {
classpath path: configurations.compile.asPath
}
}
}
}
apply from: 'gradle/utils.gradle'
def isJava16() {
System.properties['java.version'].contains('1.6')
}
def isJava15() {
System.properties['java.version'].contains('1.5')
}
def modules() {
subprojects.findAll { it.name =~ /groovy-(?!all-tests)/ }
}
// provide to other build scripts
ext.isJava6 = this.&isJava16()
ext.isJava5 = this.&isJava15()
ext.modules = this.&modules()
task dgmConverter(type: JavaExec, dependsOn: 'classes') {
description = 'Generates DGM info file required for faster startup.'
ext.classesDir = sourceSets.main.output.classesDir
classpath = files(classesDir) + configurations.compile
main = 'org.codehaus.groovy.tools.DgmConverter'
args = ['--info', classesDir.absolutePath]
doFirst {
file("$classesDir/META-INF").mkdirs()
}
inputs.files fileTree(dir: projectDir, includes: ['src/**/*GroovyMethods.java'])
outputs.file file("$classesDir/META-INF/dgminfo")
}
task compilerDgmConverter(type: JavaExec) {
description = 'Generates DGM info file for the bootstrap compiler'
ext.compilerClassesDir = sourceSets.compiler.output.classesDir
classpath = files(compilerClassesDir) + configurations.compilerCompile
main = 'org.codehaus.groovy.tools.DgmConverter'
args = ['--info', compilerClassesDir.absolutePath]
doFirst {
file("$compilerClassesDir/META-INF").mkdirs()
}
inputs.files fileTree(dir: projectDir, includes: ['src/**/*GroovyMethods.java'])
outputs.file file("$compilerClassesDir/META-INF/dgminfo")
}
compileCompilerJava {
dependsOn ensureGrammars, exceptionUtils
options.fork(memoryMaximumSize: javacMain_mx)
}
compileJava {
dependsOn compilerClasses,compilerDgmConverter,ensureGrammars
options.fork(memoryMaximumSize: javacMain_mx)
}
compileGroovy {
doFirst {
if (useIndy()) {
logger.info('Building with InvokeDynamic support activated')
}
}
groovyOptions.fork(memoryMaximumSize: groovycMain_mx)
}
compileTestGroovy {
groovyOptions.fork(memoryMaximumSize: groovycTest_mx)
}
compileExamplesGroovy {
groovyOptions.fork(memoryMaximumSize: groovycExamples_mx)
}
// suppress CheckStyle/CodeNarc
task checkstyleExamples(overwrite: true) << {}
task checkstyleMain(overwrite: true) << {}
task checkstyleTest(overwrite: true) << {}
task checkstyleTools(overwrite: true) << {}
task codenarcExamples(overwrite: true) << {}
apply from: "gradle/test.gradle"
apply from: "gradle/docs.gradle"
apply from: "gradle/assemble.gradle"
apply from: "gradle/upload.gradle"
apply from: "gradle/idea.gradle"
// Define a GroovyDoc task which depends on the generated groovydoc tool
apply from: "gradle/groovydoc.gradle"
task wrapper(type: Wrapper) {
gradleVersion = '1.4'
}
classes {
doFirst {
logger.lifecycle "InvokeDynamic support ${useIndy()?'on':'off'}"
}
}