-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle.kts
204 lines (168 loc) · 5.83 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.dsl.SpringBootExtension
plugins {
jacoco
idea
kotlin("jvm")
kotlin("kapt")
kotlin("plugin.noarg")
}
buildscript {
repositories {
maven("https://plugins.gradle.org/m2/")
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-allopen:1.8.20")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20")
}
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}
allprojects {
repositories {
maven("https://plugins.gradle.org/m2/")
mavenCentral()
}
}
subprojects {
pluginManager.withPlugin("org.springframework.boot") {
configure<SpringBootExtension> {
mainClass.set("kr.flab.movieon.MovieOnApplication")
}
}
apply {
plugin("kotlin")
plugin("io.spring.dependency-management")
plugin("org.springframework.boot")
plugin("kotlin-spring") // instead of "kotlin-allopen"
plugin("kotlin-jpa")
plugin("kotlin-kapt")
plugin("kotlin-noarg")
plugin("jacoco")
plugin("idea")
}
noArg {
// spring, jpa 가 아니라서 플러그인이 적용되지 않는 코드에 noArg 적용하는 용도로 사용한다.
annotation("kr.flab.movieon.common.annotation.NoArgsConstructor")
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("au.com.console:kassava:${Version.kassava}")
implementation("net.logstash.logback:logstash-logback-encoder:${Version.logstashLogbackEncoder}")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.kotest:kotest-runner-junit5:${Version.kotest}")
testImplementation("io.kotest:kotest-assertions-core:${Version.kotest}")
testImplementation("io.kotest.extensions:kotest-extensions-spring:${Version.kotestSpring}")
testImplementation("io.mockk:mockk:${Version.mockk}")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
}
}
sourceSets {
create("intTest") {
compileClasspath += sourceSets.main.get().output + sourceSets.test.get().output
runtimeClasspath += sourceSets.main.get().output + sourceSets.test.get().output
resources.srcDir(file("src/intTest/resources"))
}
}
tasks.withType<ProcessResources> {
// 동일한 파일(main/resources/application.yml, intTest/resources/application.yml)이 있어서, 리소스 복사할 때 충돌 회피
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
val intTestImplementation: Configuration by configurations.getting {
extendsFrom(configurations.implementation.get(), configurations.testImplementation.get())
}
configurations["intTestImplementation"].extendsFrom(configurations.testImplementation.get())
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.test {
extensions.configure(JacocoTaskExtension::class) {
setDestinationFile(file("$buildDir/jacoco/jacoco.exec"))
}
reports {
// app/build/reports/jacoco/test/html/index.html
html.required.set(true)
junitXml.required.set(true)
}
finalizedBy("integrationTest")
}
val integrationTest = task<Test>("integrationTest") {
description = "Runs integration tests."
group = "verification"
testClassesDirs = sourceSets["intTest"].output.classesDirs
classpath = sourceSets["intTest"].runtimeClasspath
maxParallelForks = 1
reports {
html.required.set(true)
junitXml.required.set(true)
}
extensions.configure(JacocoTaskExtension::class) {
setDestinationFile(file("$buildDir/jacoco/jacoco-integration.exec"))
}
shouldRunAfter("test")
finalizedBy("jacocoTestReport")
}
tasks.jacocoTestReport {
reports {
xml.required.set(true)
xml.outputLocation.set(file("$buildDir/reports/tests/jacoco.xml"))
}
shouldRunAfter("integrationTest")
}
configure<JacocoPluginExtension> {
toolVersion = "0.8.7"
}
tasks.withType<JacocoCoverageVerification> {
violationRules {
rule {
element = "BUNDLE"
limit {
counter = "BRANCH"
value = "COVEREDRATIO"
minimum = "0.0".toBigDecimal()
}
}
}
}
}
jacoco {
toolVersion = "0.8.7"
}
task<JacocoReport>("jacocoRootReport") {
dependsOn(subprojects.map { it.tasks.withType<JacocoReport>() })
sourceDirectories.setFrom(
subprojects.map {
it.tasks.findByName("jacocoTestReport")!!.property("sourceDirectories")
},
)
classDirectories.setFrom(subprojects.map { it.tasks.findByName("jacocoTestReport")!!.property("classDirectories") })
executionData.setFrom(
project.fileTree(".") {
include("**/build/jacoco/**.exec")
},
)
onlyIf {
true
}
reports {
xml.required.set(true)
html.required.set(true)
}
}