forked from spinnaker/keel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
177 lines (151 loc) · 5.47 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
import com.adarshr.gradle.testlogger.TestLoggerExtension
import com.adarshr.gradle.testlogger.theme.ThemeType.STANDARD_PARALLEL
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
//This could become id("io.spinnaker.project") in the plugins block but I'm not smart enough to
// get string interpolation working for the version in there and we need the version
// externalized for autobumping so...
classpath("io.spinnaker.gradle:spinnaker-project-plugin:${property("spinnakerGradleVersion")}")
}
}
plugins {
id("nebula.kotlin") version "1.3.72" apply false
id("org.jetbrains.kotlin.plugin.allopen") version "1.3.72" apply false
id("com.adarshr.test-logger") version "2.0.0" apply false
id("com.github.ben-manes.versions") version "0.28.0" apply false
jacoco
}
jacoco {
toolVersion = "0.8.5"
}
allprojects {
repositories {
jcenter() {
metadataSources {
artifact()
mavenPom()
}
}
mavenCentral()
if (property("korkVersion").toString().endsWith("-SNAPSHOT")) {
mavenLocal()
}
}
}
subprojects {
apply(plugin = "io.spinnaker.project")
apply(plugin = "com.github.ben-manes.versions")
group = "com.netflix.spinnaker.keel"
if (name != "keel-bom") {
apply(plugin = "nebula.kotlin")
apply(plugin = "jacoco")
dependencies {
"annotationProcessor"(platform("com.netflix.spinnaker.kork:kork-bom:${property("korkVersion")}"))
"annotationProcessor"("org.springframework.boot:spring-boot-configuration-processor")
"implementation"(platform("com.netflix.spinnaker.kork:kork-bom:${property("korkVersion")}"))
"implementation"("org.slf4j:slf4j-api")
"testImplementation"("org.junit.platform:junit-platform-runner")
"testImplementation"("org.junit.jupiter:junit-jupiter-api")
"testImplementation"("io.mockk:mockk")
"testImplementation"("org.jacoco:org.jacoco.ant:0.8.5")
"testRuntimeOnly"("org.junit.platform:junit-platform-launcher")
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
languageVersion = "1.3"
jvmTarget = "1.8"
freeCompilerArgs += "-progressive"
freeCompilerArgs += "-Xjvm-default=enable"
}
}
tasks.withType<Test> {
useJUnitPlatform {
includeEngines("junit-jupiter")
}
testLogging {
exceptionFormat = FULL
}
}
val subproject = this
tasks.withType<JacocoReport> {
logger.info("Setting up jacoco report for ${subproject.name}")
reports {
xml.isEnabled = true
csv.isEnabled = false
html.isEnabled = false
}
}
apply(plugin = "com.adarshr.test-logger")
configure<TestLoggerExtension> {
theme = STANDARD_PARALLEL
showSimpleNames = true
}
}
configurations.all {
exclude("javax.servlet", "servlet-api")
resolutionStrategy {
var okHttpVersion = "4.5.0"
force(
"com.squareup.okhttp3:okhttp:$okHttpVersion",
"com.squareup.okhttp3:okhttp-urlconnection:$okHttpVersion",
"com.squareup.okhttp3:okhttp-sse:$okHttpVersion",
"com.squareup.okhttp3:mockwebserver:$okHttpVersion",
"com.squareup.okhttp3:logging-interceptor:$okHttpVersion")
}
}
}
// Based on https://gist.github.com/tsjensen/d8b9ab9e6314ae2f63f4955c44399dad#gistcomment-3220383
fun codeCoverageProjects() = subprojects + project
task<JacocoMerge>("jacocoMerge") {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Merge the JaCoCo data files from all sub-projects into one"
afterEvaluate {
val execFiles = objects.fileCollection()
subprojects.forEach { subproject: Project ->
val testTasks = subproject.tasks.withType<Test>()
if (testTasks.isNotEmpty()) {
logger.debug("jacocoMerge depends on: ${testTasks.map { ":${subproject.name}:${it.name}" }}")
dependsOn(testTasks)
testTasks.forEach { task: Test ->
val extension = task.extensions.findByType(JacocoTaskExtension::class.java)
extension?.let {
logger.debug("jacocoMerge adding execution file ${it.destinationFile}")
execFiles.from(it.destinationFile)
}
}
}
}
executionData = execFiles
}
doFirst {
// .exec files might be missing if a project has no tests. Filter in execution phase.
executionData = executionData.filter { it.canRead() }
}
}
task<JacocoReport>("jacocoAggregateReport") {
dependsOn("jacocoMerge")
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Generates an aggregate JaCoCo report from all sub-projects"
reports {
csv.isEnabled = false
xml.isEnabled = true
html.isEnabled = true
}
afterEvaluate {
val reportTasks = subprojects.flatMap { it.tasks.withType<JacocoReport>() }
val jacocoMergeTask = tasks.named("jacocoMerge", JacocoMerge::class).get()
val destFile = jacocoMergeTask.destinationFile
logger.lifecycle("Using JaCoCo aggregate report file: $destFile")
executionData.from(destFile)
logger.debug("Adding jacoco report directories from: ${reportTasks.mapNotNull { ":${it.project.name}:${it.name}" }}")
classDirectories.from(project.files(reportTasks.mapNotNull { it.classDirectories }))
sourceDirectories.from(project.files(reportTasks.mapNotNull { it.sourceDirectories }))
}
}
defaultTasks(":keel-web:run")