-
Notifications
You must be signed in to change notification settings - Fork 52
/
build.gradle
130 lines (111 loc) · 4.18 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
/*
* Copyright 2014 Click Travel Ltd
*
* 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
*
* https://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.
*
*/
// Root Gradle project for Cheddar
def checkstyleConfigDir = new File(rootDir, 'config/checkstyle')
// Select all non-empty subprojects
def subproj = subprojects.findAll { new File(it.projectDir, "src").exists() }
// Add clean task to all projects
allprojects { apply plugin: 'base' }
// Apply site specific configuration
if (file('site.gradle').exists()) {
apply from: 'site.gradle'
} else {
ant.fail('File site.gradle is missing. Please follow the instructions in site.gradle.template to correct this.')
}
// Configuration for all subprojects, but not this root project
configure(subproj) {
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'checkstyle'
group = 'com.clicktravel'
sourceCompatibility = 1.8
idea { module { excludeDirs += file('bin') } }
// Apply common Checkstyle configuration
checkstyle {
configFile = new File(checkstyleConfigDir, "checkstyle.xml")
configProperties.checkstyleConfigDir = checkstyleConfigDir
}
configurations.all {
// Remove Jakarta Commons Logging
exclude(group: 'commons-logging', module: 'commons-logging')
}
task sourcesJar(type: Jar, dependsOn: classes) {
description 'Creates a jar file of all project sources'
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
publishing {
// Configure artifacts to publish
publications {
mavenJava(MavenPublication) {
from components.java // main artifact
artifact sourcesJar // sources artifact
}
}
}
}
task checkstyleAggregate {
description 'Aggregate Checkstyle reports and produce combined HTML report'
doLast {
def reportFiles = fileTree(rootDir).include('**/checkstyle/main.xml', '**/checkstyle/test.xml')
def reportDir = new File("${project.buildDir}/reports/checkstyle")
if (!reportDir.exists()) {
reportDir.mkdirs()
}
def file = new File("${reportDir}/aggregate.xml")
def fileElemWriter = new PrintWriter(file)
fileElemWriter.print('<checkstyle version="5.6">')
def fileElemXml = new XmlNodePrinter(fileElemWriter)
reportFiles.each { reportFile ->
new XmlParser().parse(reportFile).file.each { fileElemXml.print(it) }
}
fileElemWriter.print('</checkstyle>')
fileElemWriter.flush()
ant.xslt(in: file, style: "${checkstyleConfigDir}/checkstyle.xsl", out: "${reportDir}/checkstyle.html")
}
}
checkstyleAggregate.dependsOn { subproj.check }
ext.runIntegrationTests = System.properties['runIntegrationTests'] != null
task checkAll {
description 'Check all subprojects'
dependsOn { subproj.check }
}
def integrationTestTask = tasks.getByPath(':cheddar:cheddar-integration-aws:integrationTest')
task checkAllWithIntegrationIfNeeded {
description 'Check all subprojects and follow with integration tests if needed'
dependsOn { checkAll }
if (runIntegrationTests) {
dependsOn { integrationTestTask }
}
}
integrationTestTask.mustRunAfter checkAll
task publishAll(dependsOn: subproj.publish) {
description 'Publish source and binaries for all subprojects'
doLast {
println "Published Cheddar version ${version}"
}
}
task checkAndPublishAll {
description 'Publish source and binaries, but only if checks pass for all subprojects'
dependsOn { [checkAllWithIntegrationIfNeeded, publishAll] }
}
publishAll.mustRunAfter checkAllWithIntegrationIfNeeded
wrapper {
gradleVersion = '5.4.1'
}