-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
194 lines (170 loc) · 6.26 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
buildscript {
repositories {
mavenLocal()
maven {url "https://repo.grails.org/grails/core"}
}
dependencies {
classpath 'org.springframework.build.gradle:propdeps-plugin:+'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath "gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.13.1"
}
}
import org.gradle.internal.logging.ConsoleRenderer
plugins {
id 'base'
id 'build-dashboard'
id 'idea'
id 'eclipse'
id 'project-report'
}
project.reporting.baseDir = 'reports'
ext.unitTestFailures = 0
ext.deployDir = file('deploy')
htmlDependencyReport {
projects = project.allprojects
}
idea {
project {
languageLevel = rootProject.sourceCompatibility
vcs = 'Git'
ipr.withXml {provider ->
/**
* Setup the gradle settings to allow integration into intellij without intellig getting confused
*/
String GRADLE_HOME = System.getenv('GRADLE_HOME') ? System.getenv('GRADLE_HOME') : ''
def moduleList = modules.collect {
String contRoot = it.contentRoot.toURI().toURL().toString()
String root = rootDir.toURI().toURL().toString()
String path = contRoot.replace(root, '$PROJECT_DIR$/')
path.endsWith('/') ? path.substring(0, path.lastIndexOf('/')) : path
}
def gradleSettings = {
option(name: 'linkedExternalProjectsSettings') {
GradleProjectSettings() {
option(name: 'distributionType', value: 'DEFAULT_WRAPPED')
option(name: 'externalProjectPath', value: '$PROJECT_DIR$')
option(name: 'gradleHome', value: GRADLE_HOME)
option(name: 'modules') {
set(comment: "${modules.collect {it.name}.join(',')}") {
for (String m : moduleList) {
option(value: m)
}
}
}
}
}
}
Node gradleNode = provider.node.component.find {it.@name == 'GradleSettings'}
if (gradleNode != null) {
provider.node.remove(gradleNode)
}
provider.node.component[0].plus {
component(name: 'GradleSettings', gradleSettings)
}
if (provider.node.component.find {it.@name == 'GradleUISettings'} == null) {
provider.node.component[0].plus {
component(name: 'GradleUISettings') {
setting(name: 'root')
}
}
}
}
}
/**
* Setup the workspace (IWS) file
*/
workspace.iws.withXml {provider ->
def runManager = provider.node.component.find {it.@name == 'RunManager'}
/**
* Setup JUnit defaults to have the extra JVM options we know we need
*/
def junitDefaults = runManager.configuration.find {it.@type == 'JUnit'}
if (junitDefaults != null) {
def workingDir = junitDefaults.option.find {it.@name == 'WORKING_DIRECTORY'}
workingDir.@value = '$PROJECT_DIR$'
}
def propertiesComponent = provider.node.component.find {
it.@name == 'PropertiesComponent'
}
def dynamicclasspath = propertiesComponent.property.find {it.@name == 'dynamic.classpath'}
if (dynamicclasspath != null) {
dynamicclasspath.@value == 'true'
}
else {
propertiesComponent.property[-1].plus {
property(name: 'dynamic.classpath', value: 'true')
}
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = project.gradleVersion
}
task show() {
doLast {
logger.quiet "All seems to be working"
}
}
task test() {
group 'testing'
description = 'Runs all the tests'
dependsOn 'assemble', 'unitTest'
}
build {
description =
'Assembles the project, builds the release archive and runs the unit tests. The complete build process.'
dependsOn 'check', 'buildDashboard'
doLast {
if (unitTestFailures) {
String grammer = unitTestFailures == 1 ? 'was 1 unit test failure' : "were $unitTestFailures unit test failures"
File indexFile = file("$tasks.unitTest.destinationDir/index.html")
String reportUrl = new ConsoleRenderer().asClickableFileUrl(indexFile)
logger.quiet("There $grammer. See the report at $reportUrl. (Ctrl+click the URL to open)")
}
}
}
clean {
delete 'logs', 'reports', 'deploy'
}
/**
* Unit Test task,
* This task will generate a TestReport in HTML format for the tests which it reports on
* Any unit tests/test tasks should be set to be reported on and depended on by this task
*/
task unitTest(type: TestReport) {
description = 'Run Unit Tests and compile results into HTML report.'
destinationDir file("$rootDir/reports/unitTests")
group 'Testing'
doLast {
logger.info("Test failure count: {}", unitTestFailures)
if (unitTestFailures) {
String grammer = unitTestFailures == 1 ? 'was 1 unit test failure' : "were $unitTestFailures unit test failures"
File indexFile = file("$destinationDir/index.html")
String reportUrl = new ConsoleRenderer().asClickableFileUrl(indexFile)
logger.quiet("There $grammer. See the report at $reportUrl. (Ctrl+click the URL to open)")
}
}
dependsOn tasks.assemble
}
task reportOnLicenses {
group 'license'
}
check.dependsOn 'reportOnLicenses'
apply from: 'gradle/allprojects.gradle'
apply from: 'gradle/subprojects.gradle'
evaluationDependsOnChildren()
afterEvaluate {
tasks.findAll {task -> ['assemble', 'build', 'clean', 'check', 'install'].contains(task.name)}.each {task ->
def deps = (subprojects.tasks.collect {
it.findByName(task.name)
}.flatten() as Set) - null
if (deps) {
task.dependsOn.each {
if (deps.contains(it)) {
deps = deps - it
}
}
deps.each {task.dependsOn it.path}
}
}
}