-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
179 lines (145 loc) · 5.17 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
import com.epages.restdocs.apispec.gradle.OpenApi3Extension
import com.epages.restdocs.apispec.gradle.OpenApi3Task
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
/**
* [Plugin Collect]
* - 사용할 플러그인을 정의하는 곳이다.
*/
plugins {
id("org.springframework.boot") apply false
id("io.spring.dependency-management") apply false
id("org.jmailen.kotlinter")
id("java-test-fixtures")
id("com.epages.restdocs-api-spec") apply false
kotlin("jvm")
kotlin("kapt")
kotlin("plugin.spring") apply false
kotlin("plugin.jpa") apply false
}
allprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jetbrains.kotlin.kapt")
apply(plugin = "org.jmailen.kotlinter")
group = "com.meloning"
version = "0.0.1"
repositories {
mavenCentral()
}
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.formatKotlinMain {
exclude {
it.file.path.contains("generated/")
}
}
tasks.lintKotlinMain {
exclude { it.file.path.contains("generated/")}
}
}
val kopringProjects = listOf(
project(":mega-coffee-scheduler"),
project(":mega-coffee-api"),
project(":mega-coffee-core"),
project(":mega-coffee-core-infra"),
project(":mega-coffee-common"),
project(":mega-coffee-infra:database:mysql"),
project(":mega-coffee-infra:message-queue:rabbitmq"),
project(":clients:java-email"),
project(":event-consumer:event-api")
)
configure(kopringProjects) {
apply(plugin = "org.jetbrains.kotlin.plugin.spring")
apply(plugin = "org.springframework.boot")
apply(plugin = "io.spring.dependency-management")
val mockitoKotlinVersion: String by project
the<DependencyManagementExtension>().apply {
imports {
val testContainersVersion: String by project
mavenBom("org.testcontainers:testcontainers-bom:${testContainersVersion}")
}
}
dependencies {
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion")
}
}
val integrationTestProjects = listOf(
project(":mega-coffee-infra:database:mysql"),
project(":mega-coffee-infra:message-queue:rabbitmq")
)
configure(integrationTestProjects) {
apply(plugin = "java-test-fixtures")
dependencies {
testFixturesApi("org.testcontainers:testcontainers")
testFixturesApi("org.testcontainers:junit-jupiter")
}
}
val querydslProjects = listOf(
project(":mega-coffee-infra:database:mysql")
)
configure(querydslProjects) {
val querydslVersion: String by project
dependencies {
kapt("com.querydsl:querydsl-kotlin-codegen:$querydslVersion")
kapt("org.springframework.boot:spring-boot-configuration-processor")
}
}
val restDocsProjects = listOf(
project(":mega-coffee-api"), // Admin API가 추가될 수 있으니 list로 미리 선언
)
configure(restDocsProjects) {
apply(plugin = "com.epages.restdocs-api-spec")
extra["snippetsDir"] = file("build/generated-snippets")
val snippetsDir = extra["snippetsDir"] as File
val initialDocsFile = File("${project.file("src/test/resources")}/docs/initial-overview.md")
val epagesApiDocsVersion: String by project
dependencies {
testImplementation("org.springframework.restdocs:spring-restdocs-mockmvc")
testImplementation("com.epages:restdocs-api-spec:$epagesApiDocsVersion")
testImplementation("com.epages:restdocs-api-spec-mockmvc:$epagesApiDocsVersion")
}
/**
* @see <a href="https://github.com/ePages-de/restdocs-api-spec">Spring REST Docs API specification Integration</a>
*/
configure<OpenApi3Extension> {
setServer("http://localhost:9000")
title = "MGC Employee Manage OAS"
version = "1.0.0"
description = initialDocsFile.readText()
format = "yaml"
outputFileNamePrefix = "incomplete_openapi3"
}
tasks.withType(OpenApi3Task::class) {
finalizedBy("removeBlockScalarsFromYaml")
}
tasks.register("removeBlockScalarsFromYaml") {
dependsOn("openapi3")
doLast {
val inputFile = File("${project.buildDir}/api-spec/incomplete_openapi3.yaml")
val outputFile = File("${project.buildDir}/api-spec/openapi3.yaml")
val yamlData = inputFile.readText()
val cleanedYamlData = yamlData.replace(Regex("value: \\|-"), "value:")
outputFile.writeText(cleanedYamlData)
}
}
}
kotlinter {
ignoreFailures = false
reporters = arrayOf("checkstyle", "plain")
experimentalRules = false
disabledRules = emptyArray()
}