-
Notifications
You must be signed in to change notification settings - Fork 52
/
build.gradle.kts
294 lines (245 loc) · 9.98 KB
/
build.gradle.kts
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
plugins {
idea
id("com.github.johnrengelman.shadow") version "5.2.0" apply false
}
/*
* Set <code>./gradlew -PuseBuildScan=true</code> to activate the build scan plugin
* and service in order to visualize build/test failures.
* The corresponding plugin is applied in the <code>settings.gradle.kts</code> file.
*/
val useBuildScan: String? by project
if (useBuildScan != null && useBuildScan.equals("true", true)) {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
publishOnFailure()
}
}
// Adjust Intellij module configuration for main project
idea {
module {
excludeDirs.addAll(mutableListOf(file("docs/.jekyll-cache"), file("docs/_site"), file("docs/node_modules")))
}
}
subprojects {
val projectToConf = this
apply(plugin = "idea")
apply(plugin = "eclipse")
apply(plugin = "java")
apply(plugin = "pmd")
/*
* Apply default plugins and IntelliJ module configuration
* for all sub-projects
*/
idea {
module {
excludeDirs.addAll(mutableListOf(file("bin"), file("lib"), file("libs")))
}
}
repositories {
mavenCentral()
}
configurations {
create("testing") // used to reference the testJar
create("testConfig") // contains test dependencies that are used by all java subprojects
create("releaseDep") { // contains all dependencies which has to be included into the release jar/zip
isTransitive = false // avoid that the whole dependency tree is released
}
}
configure<PmdExtension> {
toolVersion = "6.22.0"
isConsoleOutput = true
ruleSetFiles = files(rootProject.file("ruleset.xml"))
ruleSets = emptyList<String>()
}
tasks {
// Otherwise our custom tags (as "@JTourBus") let the javadoc generation fail
withType<Javadoc> {
isFailOnError = false
}
withType<Test> {
// Disable jmx in the test environment to avoid issues with easymock
systemProperty("log4j2.disableJmx", "true")
/* Exclude test suites if property is set. Otherwise tests are executed multiple times
* in the ci server (via test class and suite).
* see gradle.properties for default values
*/
val skipTestSuites: String? by project
if (skipTestSuites != null && skipTestSuites.equals("true", true)) {
exclude("**/*TestSuite*")
}
/*
* Exclude STF tests if property is set. Otherwise the STF self-tests (which are reliant on test
* workers to function properly) are also run when executing the 'test' task to run all Saros
* test.
*/
val skipSTFTests: String? by project
if (skipSTFTests != null && skipSTFTests.equals("true", true)) {
exclude("saros/stf/test/stf/*")
}
// Don't execute abstract test classes
exclude("**/Abstract*")
testLogging {
showStandardStreams = true
events("passed", "skipped", "failed", "standardOut", "standardError")
}
}
/* generate lib directory that contains all release dependencies
* This is necessary to enable eclipse to run the stf tests, because
* eclipse uses the path of the MANIFEST.MF and is not compatible with
* gradle dependency resolution
*/
register("generateLib", Copy::class) {
into("${project.projectDir}/lib")
from(projectToConf.configurations.getByName("releaseDep"))
}
val aggregateTestResults: String? by project
if (aggregateTestResults != null && aggregateTestResults.equals("true", true)) {
val test by getting {}
val copyReport = register("copyReport", Copy::class) {
from("build/reports/tests/test")
into("$rootDir/build/reports/allTests/${projectToConf.name}")
}
test.finalizedBy(copyReport)
}
}
/*
* Define default eclipse version that is used for resolving
* dependencies and building the update site.
*/
projectToConf.extra["eclipseVersion"] = "4.8.0"
/*
* Make common dependency definitions accessible by all sub-projects
*/
val junitVersion = "junit:junit:4.12"
val log4j2VersionNr = "2.18.0"
val log4j2Api = "org.apache.logging.log4j:log4j-api:$log4j2VersionNr"
val log4j2Core = "org.apache.logging.log4j:log4j-core:$log4j2VersionNr"
// Bridge that routes log4j calls to log4j2
val log4j2Bridge = "org.apache.logging.log4j:log4j-1.2-api:$log4j2VersionNr"
projectToConf.extra["junitVersion"] = junitVersion
projectToConf.extra["log4j2ApiVersion"] = log4j2Api
projectToConf.extra["log4j2CoreVersion"] = log4j2Core
projectToConf.extra["log4j2BridgeVersion"] = log4j2Bridge
dependencies {
val testConfig by configurations
testConfig(log4j2Api)
testConfig(log4j2Core)
testConfig(log4j2Bridge)
testConfig(junitVersion)
testConfig("org.easymock:easymock:4.0.1")
testConfig("org.powermock:powermock-core:2.0.5")
testConfig("org.powermock:powermock-module-junit4:2.0.5")
testConfig("org.powermock:powermock-api-easymock:2.0.5")
}
/*
* Properties:
* Set <code>./gradlew -PintellijHome=<path to IntelliJ></code> to use
* a local installation for build and test.
*
* Set <code>./gradlew -PversionQualifier=<qualifier></code> to define
* a version qualifier for CI build results.
*/
val intellijHome: String? by project
val versionQualifier: String? by project
projectToConf.extra["intellijHome"] = intellijHome ?: System.getenv("INTELLIJ_HOME")
projectToConf.extra["intellijSandboxDir"] = System.getenv("SAROS_INTELLIJ_SANDBOX") ?: ""
projectToConf.extra["versionQualifier"] = if (versionQualifier.isNullOrBlank()) "" else ".$versionQualifier"
}
tasks {
/* Internal Tasks (not intended to be called by users) */
// generate all lib dirs in order to run stf tests
register("generateLibAll") {
dependsOn(
"cleanGenerateLibAll",
":saros.core:generateLib",
":saros.eclipse:generateLib",
":saros.stf:generateLib",
":saros.stf.test:generateLib")
}
register("cleanGenerateLibAll") {
doLast {
project(":saros.eclipse").file("lib").deleteRecursively()
project(":saros.core").file("lib").deleteRecursively()
project(":saros.stf").file("lib").deleteRecursively()
project(":saros.stf.test").file("lib").deleteRecursively()
}
}
/* External Tasks */
// TODO: Verify whether this task is used
register("aggregatedTestReport", TestReport::class) {
destinationDir = file("$buildDir/reports/allTests")
val testProjects = (subprojects - project(":saros.stf") - project(":saros.stf.test"))
reportOn(testProjects.map { it.tasks.getByName("test") })
group = "Report"
description = "Triggers the test task on all sub-projects and aggregates the report in a single report"
}
// remove all build dirs. The frontend package has no build directory
register("prepareEclipse") {
dependsOn(
subprojects.map { listOf(":${it.name}:cleanEclipseProject", ":${it.name}:cleanEclipseClasspath") }.flatten() +
subprojects.map { listOf(":${it.name}:eclipseProject", ":${it.name}:eclipseClasspath") }.flatten() +
listOf("generateLibAll", ":saros.eclipse:copyLogFiles")
)
group = "IDE"
description = "Generates the 'libs' directories containing the " +
"dependencies and generates the eclipse configurations for all projects"
}
register("cleanAll") {
dependsOn(subprojects.map { ":${it.name}:clean" })
group = "Build"
description = "Utility task that calls 'clean' of all sub-projects"
}
register("sarosEclipse", Copy::class) {
dependsOn(
":saros.core:test",
":saros.eclipse:test",
":saros.eclipse:jar")
group = "Build"
description = "Builds and tests all modules required by Saros for Eclipse"
from(project(":saros.core").tasks.findByName("jar"))
from(project(":saros.eclipse").tasks.findByName("jar"))
into("build/distribution/eclipse")
}
register("sarosStf", Copy::class) {
dependsOn(
"sarosEclipse",
"saros.stf:jar"
)
from(project(":saros.stf").tasks.findByName("jar"))
into("build/distribution/eclipse")
}
register("sarosServer", Copy::class) {
dependsOn(
":saros.core:test",
":saros.server:test",
":saros.server:jar")
group = "Build"
description = "Builds and tests all modules required by the Saros Server"
from(project(":saros.server").tasks.findByName("jar"))
into("build/distribution/server")
}
register("sarosLsp", Copy::class) {
dependsOn(
":saros.core:test",
":saros.lsp:test",
":saros.lsp:jar"
)
group = "Build"
description = "Builds and tests all modules required by the Saros Language Server"
from(project(":saros.lsp").tasks.findByName("jar"))
into("build/distribution/lsp")
}
register("sarosIntellij", Copy::class) {
dependsOn(
":saros.core:test",
":saros.intellij:test",
":saros.intellij:buildPlugin"
)
group = "Build"
description = "Builds and tests all modules required by Saros for Intellij"
from(project(":saros.intellij").configurations.getByName("archives").artifacts.files)
include("*.zip")
into("build/distribution/intellij")
}
}