-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
540 lines (455 loc) · 16.2 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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
/*
* Copyright 2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.gradle.build.Version
import org.gradle.build.Install
import org.gradle.build.Git
import org.gradle.build.Releases
/**
* For building Gradle you usually don't need to specify any properties. Only certain functionality of the Gradle requires
* setting certain properties. Those properties can be set in the gradle.properties file in the the gradle user home. The
* following properties can be set:
*
* Uploading distributions to Gradle's release and snapshot repository at codehaus: artifactoryUserName, artifactoryUserPassword
* Uploading the userguide and the javadoc to Gradle's website: websiteScpUserName, websiteScpUserPassword
* Using the build to create a new distribution and install it on the local machine: gradle_installPath
*/
ext.releases = new Releases(project(':core').file('src/releases.xml'), project)
version = Version.forProject(project)
defaultTasks 'assemble'
apply plugin: 'java-base'
archivesBaseName = 'gradle'
ext {
versions = [
commons_io: 'commons-io:commons-io:1.4'
]
libraries = [
ant: dependencies.module('org.apache.ant:ant:1.8.2') {
dependency 'org.apache.ant:ant-launcher:1.8.2@jar'
},
asm: 'asm:asm-all:3.3.1@jar',
commons_cli: 'commons-cli:commons-cli:1.2@jar',
commons_io: dependencies.module(versions.commons_io),
commons_lang: 'commons-lang:commons-lang:2.6@jar',
commons_collections: 'commons-collections:commons-collections:3.2.1@jar',
ivy: dependencies.module('org.apache.ivy:ivy:2.2.0'){
dependency "com.jcraft:jsch:0.1.46"
},
jcip: "net.jcip:jcip-annotations:1.0@jar",
]
}
// Logging
libraries.slf4j_api = 'org.slf4j:slf4j-api:1.6.4@jar'
libraries.jcl_to_slf4j = dependencies.module('org.slf4j:jcl-over-slf4j:1.6.4') {
dependency libraries.slf4j_api
}
libraries.jul_to_slf4j = dependencies.module('org.slf4j:jul-to-slf4j:1.6.4') {
dependency libraries.slf4j_api
}
libraries.log4j_to_slf4j = dependencies.module('org.slf4j:log4j-over-slf4j:1.6.4') {
dependency libraries.slf4j_api
}
libraries.logback_core = 'ch.qos.logback:logback-core:1.0.0@jar'
libraries.logback_classic = dependencies.module('ch.qos.logback:logback-classic:1.0.0') {
dependency libraries.logback_core
dependency libraries.slf4j_api
}
// Jetty
libraries.servlet_api = "org.mortbay.jetty:servlet-api:2.5-20081211@jar"
libraries.jetty_util = dependencies.module("org.mortbay.jetty:jetty-util:6.1.25") {
dependency libraries.slf4j_api
dependency libraries.servlet_api
}
libraries.jetty = dependencies.module("org.mortbay.jetty:jetty:6.1.25") {
dependency libraries.jetty_util
dependency libraries.servlet_api
}
libraries.commons_httpclient = dependencies.module('org.apache.httpcomponents:httpclient:4.1.2') {
dependency "org.apache.httpcomponents:httpcore:4.1.2@jar"
dependency libraries.jcl_to_slf4j
dependency "commons-codec:commons-codec:1.4@jar"
dependency "org.samba.jcifs:jcifs:1.3.17"
}
libraries.maven_ant_tasks = dependencies.module("org.apache.maven:maven-ant-tasks:2.1.3") {
libraries.ant
}
libraries += [
ant_junit: 'org.apache.ant:ant-junit:1.8.2@jar',
ant_antlr: 'org.apache.ant:ant-antlr:1.8.2@jar',
antlr: 'antlr:antlr:2.7.7@jar',
dom4j: 'dom4j:dom4j:1.6.1@jar',
guava: 'com.google.guava:guava:11.0.1@jar',
groovy: 'org.codehaus.groovy:groovy-all:1.8.6@jar',
jaxen: 'jaxen:jaxen:1.1@jar',
jcip: "net.jcip:jcip-annotations:1.0",
jna: 'net.java.dev.jna:jna:3.2.7@jar',
junit: 'junit:junit:4.10',
xmlunit: 'xmlunit:xmlunit:1.3',
nekohtml: 'net.sourceforge.nekohtml:nekohtml:1.9.14'
]
libraries.spock = ['org.spockframework:spock-core:0.6-groovy-1.8@jar',
libraries.groovy,
'org.objenesis:objenesis:1.2',
'cglib:cglib-nodep:2.2']
libraries.jmock = ['org.jmock:jmock:2.5.1',
'org.hamcrest:hamcrest-core:1.1',
'org.hamcrest:hamcrest-library:1.1',
'org.jmock:jmock-junit4:2.5.1',
'org.jmock:jmock-legacy:2.5.1',
'org.objenesis:objenesis:1.2',
'cglib:cglib-nodep:2.2']
allprojects {
group = 'org.gradle'
plugins.withType(JavaPlugin) {
sourceCompatibility = 1.5
targetCompatibility = 1.5
}
repositories {
maven { url 'http://repo.gradle.org/gradle/libs' }
maven { url 'http://repository.codehaus.org/' }
}
configurations {
all {
resolutionStrategy {
//we cannot use 'hours' for now due to java 1.5 problem
cacheDynamicVersionsFor 24*60*60, 'seconds'
cacheChangingModulesFor 24*60*60, 'seconds'
}
}
}
version = this.version
apply from: "$rootDir/gradle/conventions-dsl.gradle"
ext {
isDevBuild = {
gradle.taskGraph.hasTask(developerBuild)
}
isCIBuild = {
gradle.taskGraph.hasTask(ciBuild)
}
isCommitBuild = {
gradle.taskGraph.hasTask(commitBuild)
}
isFinalReleaseBuild = {
gradle.taskGraph.hasTask(releaseVersion)
}
isRcBuild = {
gradle.taskGraph.hasTask(rcVersion)
}
isNightlyBuild = {
gradle.taskGraph.hasTask(nightlyVersion)
}
isReleaseBuild = { // Are we doing any kind of “release”? i.e. final, nightly or rc
isFinalReleaseBuild() || isNightlyBuild() || isRcBuild()
}
}
}
configure(groovyProjects()) {
apply from: "$rootDir/gradle/groovyProject.gradle"
}
configure(publishedProjects()) {
apply from: "$rootDir/gradle/publish.gradle"
}
allprojects {
apply from: "$rootDir/gradle/codeQuality.gradle"
apply from: "$rootDir/gradle/testWithUnknownOS.gradle"
}
apply from: "gradle/idea.gradle"
apply from: "gradle/eclipse.gradle"
configurations {
dists
runtime {
visible = false
}
plugins {
visible = false
}
testRuntime {
extendsFrom runtime
extendsFrom plugins
}
}
dependencies {
runtime project(':launcher')
plugins pluginProjects()
plugins project(':coreImpl')
}
evaluationDependsOn(':docs')
evaluationDependsOn(':integTest')
clean.dependsOn subprojects.collect { "$it.path:clean" }
task check(overwrite: true, dependsOn: groovyProjects()*.check)
check.dependsOn ':docs:checkstyleApi'
configure(groovyProjects()) {
check.dependsOn ":docs:checkstyleApi"
}
task test(overwrite: true, dependsOn: groovyProjects()*.test)
task uploadArchives(dependsOn: publishedProjects()*.uploadArchives)
task publishLocalArchives(dependsOn: publishedProjects()*.publishLocalArchives)
task aggregateTestReports(type: TestReportAggregator) {
testReportDir = reporting.file("tests")
testResultsDir = file("${buildDir}/test-results")
projects = subprojects
}
ext.zipRootFolder = "$archivesBaseName-${-> version}"
ext.binDistImage = copySpec {
from('src/toplevel') {
exclude 'media/**'
expand(version: version)
}
from('src/toplevel') {
include 'media/**'
}
from project(':docs').outputs.distDocs
into('bin') {
from { project(':launcher').startScripts.outputs.files }
fileMode = 0755
}
into('lib') {
from configurations.runtime
into('plugins') {
from configurations.plugins - configurations.runtime
}
}
}
ext.allDistImage = copySpec {
with binDistImage
into('src') {
from groovyProjects().collect {project -> project.sourceSets.main.allSource }
}
into('docs') {
from project(':docs').outputs.docs
}
into('samples') {
from project(':docs').outputs.samples
}
}
task allZip(type: Zip) {
classifier = 'all'
into(zipRootFolder) {
with allDistImage
}
}
task binZip(type: Zip) {
classifier = 'bin'
into(zipRootFolder) {
with binDistImage
}
}
task srcZip(type: Zip) {
classifier = 'src'
into(zipRootFolder) {
from('gradlew') {
fileMode = 0755
}
from(projectDir) {
def spec = delegate
['buildSrc', 'subprojects/*'].each {
spec.include "$it/*.gradle"
spec.include "$it/src/"
}
include 'config/'
include 'gradle/'
include 'src/'
include '*.gradle'
include 'wrapper/'
include 'gradlew.bat'
}
}
}
artifacts {
tasks.withType(Zip).each {
dists it
}
}
task intTestImage(type: Sync) {
dependsOn "launcher:startScripts"
with binDistImage
ext.integTestGradleHome = file("$buildDir/integ test")
into integTestGradleHome
doLast { task ->
ant.chmod(dir: "$integTestGradleHome/bin", perm: "ugo+rx", includes: "**/*")
}
}
gradle.taskGraph.whenReady {
if (([isFinalReleaseBuild(), isNightlyBuild(), isRcBuild()].findAll { it }).size() > 1) {
throw new GradleException("This appears to be more than one type of release: final - ${isFinalReleaseBuild()}, rc - ${isRcBuild()}, nightly - ${isNightlyBuild() }")
}
}
def guessMaxForks(project) {
if (project.hasProperty("maxParallelForks")) {
return Integer.valueOf(project.getProperty("maxParallelForks"))
}
int processors = Runtime.runtime.availableProcessors()
return Math.max(2, (int) (processors / 2))
}
task install(type: Install) {
description = 'Installs the minimal distribution into directory $gradle_installPath'
group = 'build'
dependsOn binZip.taskDependencies
with binDistImage
installDirProperyName = 'gradle_installPath'
}
task installAll(type: Install) {
description = 'Installs the full distribution into directory $gradle_installPath'
group = 'build'
dependsOn allZip.taskDependencies
with allDistImage
installDirProperyName = 'gradle_installPath'
}
task testedDists(dependsOn: [check]) {
outputs.files configurations.dists.allArtifacts.files
}
gradle.taskGraph.whenReady {graph ->
if (graph.hasTask(uploadArchives)) {
// check properties defined and fail early
artifactoryUserName
artifactoryUserPassword
}
}
task quickCheck {
def i = gradle.startParameter.taskNames.findIndexOf { it ==~ /(?i):?(quickCheck|qC)/ }
if (i >= 0) {
gradle.startParameter.taskNames.addAll(i, ["doc:checkstyleApi", "codeQuality", "classes", "test"])
}
doFirst {
if (i < 0) {
throw new GradleException("Due to the way it is implemented, the 'quickCheck' task has to be invoked directly, and its name can only be abbreviated to 'qC'.")
}
}
}
task developerBuild {
description = 'Builds distributions and runs pre-checkin checks'
group = 'build'
dependsOn testedDists
}
task ciBuild {
description = 'Full build performed by the CI server'
dependsOn clean, testedDists
}
task commitBuild {
description = 'Commit build performed by the CI server'
dependsOn testedDists
}
task nightlyVersion
task checkJavaVersion << {
assert Jvm.current().isJava7() : "Must use a Java 7 compatible JVM to perform this build. Current JVM is ${Jvm.current()}"
}
task nightlyBuild {
description = 'Nightly build performed by the CI server'
dependsOn checkJavaVersion, nightlyVersion, testedDists, "uploadAll"
}
gradle.taskGraph.whenReady {graph ->
if (graph.hasTask(ciBuild)) {
subprojects { reportsDirName = "$rootProject.reportsDir/${path.replaceFirst(':', '').replaceAll(':', '.')}" }
}
}
// A marker task which causes the release version to be used when it is present in the task graph
task releaseVersion
//TODO SF - this task name is inconsistent because other releaseXxx tasks actually upload some content somewhere. Should be called something like 'markReleaseVersion'
// A marker task which indicates that we are building an rc of some sort
task rcVersion
//TODO RG - we depend here on the alphabetical order of dependent task execution. We Should change that to fail early if javaversion is inappropriate
task rc {
description "Builds a release candidate for the next release"
dependsOn checkJavaVersion, rcVersion, testedDists, "uploadAll"
}
task tag(type: Tag)
task testedTag(type: Tag, dependsOn: testedDists)
task releaseArtifacts {
description = 'Builds the release artifacts'
//TODO SF - this task name is inconsistent because other releaseXxx tasks actually upload some content somewhere. Should be called something like 'buildReleaseArtifacts'
group = 'release'
dependsOn releaseVersion, assemble
}
//TODO RG - we depend here on the alphabetical order of dependent task execution. We Should change that to fail early if javaversion is inappropriate
task release {
description = 'Builds, tests and uploads the release artifacts'
group = 'release'
dependsOn releaseVersion, checkJavaVersion, testedTag, releaseArtifacts, testedDists, 'uploadAll'
doLast {
releases.incrementNextVersion()
}
}
task incrementNextVersion << {
releases.incrementNextVersion()
}
task uploadAll {
description = 'Uploads binaries, sources and documentation. Does not upload the website! Useful when release procedure breaks at upload and only upload tasks should executed again'
dependsOn uploadArchives, "website:uploadDistributions", "website:uploadDocs", "website:pushReleasesXml"
}
def wrapperUpdateTask = { name, label ->
task "${name}Wrapper"(type: Wrapper) {
doFirst {
def version = new groovy.json.JsonSlurper().parseText(new URL("http://services.gradle.org/versions/$label").text)
if (version.empty) {
throw new GradleException("Cannot update wrapper to '${label}' version as there is currently no version of that label")
}
println "updating wrapper to $label version: $version.version (downloadUrl: $version.downloadUrl)"
distributionUrl version.downloadUrl
}
doLast {
def jvmOpts = "-Xmx1024m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8"
inputs.property("jvmOpts", jvmOpts)
def optsEnvVar = "DEFAULT_JVM_OPTS"
scriptFile.write scriptFile.text.replace("$optsEnvVar=\"\"", "$optsEnvVar=\"$jvmOpts\"")
batchScript.write batchScript.text.replace("set $optsEnvVar=", "set $optsEnvVar=$jvmOpts")
}
}
}
wrapperUpdateTask("nightly", "nightly")
wrapperUpdateTask("rc", "release-candidate")
wrapperUpdateTask("current", "current")
def groovyProjects() {
subprojects.findAll { !(it.name in ["docs", "website"]) }
}
def publishedProjects() {
[project(':core'), project(':toolingApi'), project(':wrapper'), project(':baseServices')]
}
def pluginProjects() {
['plugins', 'codeQuality', 'jetty', 'antlr', 'wrapper', 'osgi', 'maven', 'ide', 'announce', 'scala', 'sonar', 'signing', 'cpp', 'ear'].collect {
project(it)
}
}
class TestReportAggregator extends Copy {
def projects
File testResultsDir
@OutputDirectory
File testReportDir
def TestReportAggregator() {
dependsOn { testTasks }
from { inputTestResultDirs }
into { testResultsDir }
}
@TaskAction
def aggregate() {
def report = new org.gradle.api.internal.tasks.testing.junit.report.DefaultTestReport(testReportDir: testReportDir, testResultsDir: testResultsDir)
report.generateReport()
}
def getTestTasks() {
projects.collect { it.tasks.withType(Test) }.flatten()
}
def getInputTestResultDirs() {
testTasks*.testResultsDir
}
}
class Tag extends DefaultTask {
@TaskAction
def tagNow() {
def version = project.version
def git = new Git(project)
git.checkNoModifications()
git.tag("REL_$version", "Release $version")
git.branch("RB_$version")
}
}