-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle.kts
220 lines (187 loc) · 6.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jooq.meta.jaxb.Logging
import org.springframework.boot.gradle.tasks.bundling.BootJar
plugins {
id("org.springframework.boot")
id("io.spring.dependency-management")
id("org.jlleitschuh.gradle.ktlint")
id("nu.studer.jooq")
kotlin("jvm")
kotlin("plugin.spring")
kotlin("plugin.jpa")
jacoco
}
group = "${property("projectGroup")}"
version = "${property("applicationVersion")}"
val javaVersion = "${property("javaVersion")}"
val testContainerVersion = "${property("testContainerVersion")}"
val restdocsApiVersion = "${property("restdocsApiVersion")}"
val springMockkVersion = "${property("springMockkVersion")}"
val autoParamsVersion = "${property("autoParamsVersion")}"
val jacocoVersion = "${property("jacocoVersion")}"
val jooqVersion = "${property("jooqVersion")}"
tasks.withType<Jar> {
enabled = false
}
tasks.withType<BootJar> {
enabled = true
}
java {
sourceCompatibility = JavaVersion.valueOf("VERSION_$javaVersion")
}
repositories {
mavenCentral()
maven { url = uri("https://repo.spring.io/milestone") }
}
dependencies {
// kotlin
implementation("org.jetbrains.kotlin:kotlin-reflect")
// spring
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-data-redis")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-web")
// springDoc
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0")
// convert
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
// database
runtimeOnly("org.postgresql:postgresql")
implementation("org.liquibase:liquibase-core")
jooqGenerator("org.jooq:jooq-meta-extensions-liquibase")
jooqGenerator("org.liquibase:liquibase-core")
// aws
implementation("software.amazon.awssdk:s3:2.22.12")
// test
testImplementation("org.testcontainers:postgresql")
testImplementation("org.testcontainers:testcontainers:$testContainerVersion")
testImplementation("org.testcontainers:junit-jupiter:$testContainerVersion")
testImplementation("org.testcontainers:jdbc:$testContainerVersion")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(module = "mockito-core")
}
testImplementation("org.springframework.boot:spring-boot-testcontainers")
testImplementation("org.springframework.restdocs:spring-restdocs-mockmvc")
testImplementation("com.epages:restdocs-api-spec-mockmvc:$restdocsApiVersion")
testImplementation("com.ninja-squad:springmockk:$springMockkVersion")
testImplementation("io.github.autoparams:autoparams-kotlin:$autoParamsVersion")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = javaVersion
}
}
jooq {
version.set(dependencyManagement.importedProperties["jooq.version"])
configurations {
create("main") {
jooqConfiguration.apply {
logging = Logging.WARN
generator.apply {
name = "org.jooq.codegen.DefaultGenerator"
database.apply {
name = "org.jooq.meta.extensions.liquibase.LiquibaseDatabase"
properties.add(
org.jooq.meta.jaxb.Property().withKey("rootPath")
.withValue("${project.projectDir}/src/main/resources")
)
properties.add(
org.jooq.meta.jaxb.Property().withKey("scripts")
.withValue("/db/changelog-master.yml")
)
}
generate.apply {
isDeprecated = false
isRecords = true
isImmutablePojos = true
isFluentSetters = true
}
target.apply {
packageName = "com.mjucow.eatda.jooq"
}
strategy.name = "org.jooq.codegen.DefaultGeneratorStrategy"
}
}
}
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.test {
extensions.configure(JacocoTaskExtension::class) {
setDestinationFile(file("$buildDir/jacoco/jacoco.exec"))
}
finalizedBy(tasks.jacocoTestReport)
}
jacoco {
toolVersion = jacocoVersion
}
tasks.jacocoTestReport {
reports {
html.required = true
xml.required = true
csv.required = false
}
dependsOn(tasks.test)
finalizedBy("jacocoTestCoverageVerification")
}
tasks.jacocoTestCoverageVerification {
violationRules {
rule {
// 'element'가 없으면 프로젝트의 전체 파일을 합친 값을 기준으로 한다.
limit {
// 'counter'를 지정하지 않으면 default는 'INSTRUCTION'
// 'value'를 지정하지 않으면 default는 'COVEREDRATIO'
minimum = "0.30".toBigDecimal()
}
}
rule {
enabled = true
// 룰을 체크할 단위는 클래스 단위
element = "CLASS"
// 브랜치 커버리지를 최소한 80% 만족시켜야 한다.
limit {
counter = "BRANCH"
value = "COVEREDRATIO"
minimum = "0.80".toBigDecimal()
}
// 라인 커버리지를 최소한 80% 만족시켜야 한다.
limit {
counter = "LINE"
value = "COVEREDRATIO"
minimum = "0.70".toBigDecimal()
}
// 빈 줄을 제외한 코드의 라인수를 최대 200라인으로 제한한다.
limit {
counter = "LINE"
value = "TOTALCOUNT"
maximum = "200".toBigDecimal()
}
// 커버리지 체크를 제외할 클래스들
excludes = listOf(
"com.mjucow.eatda.EatdaApplicationKt",
"*.*ApiPresentation.*",
"*.common.*",
"*.dto.*",
"com.mjucow.eatda.jooq.*",
"*.Companion",
"*.s3.*",
"*.popularstore.*", // FIXME: redis 이슈 해결 후 제거
"*.health.*"
)
}
}
}
val testCoverage by tasks.registering {
group = "verification"
description = "Runs the unit tests with coverage"
dependsOn(
":test",
":jacocoTestReport",
":jacocoTestCoverageVerification"
)
tasks["jacocoTestReport"].mustRunAfter(tasks["test"])
tasks["jacocoTestCoverageVerification"].mustRunAfter(tasks["jacocoTestReport"])
}