-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
164 lines (136 loc) · 4.5 KB
/
build.gradle
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
plugins {
id 'org.springframework.boot' version '2.5.6'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
// Asciidoctor 플러그인 적용
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'jacoco'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
asciidoctorExtensions
}
repositories {
mavenCentral()
}
jacoco {
toolVersion = "0.8.7"
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
// Hot Reload 적용하기위해 추가
implementation group: 'org.springframework.boot', name: 'spring-boot-devtools'
// .adoc 파일에서 빌드, 스니펫 생성을 자동으로 구성되기 위해 추가하는 의존성
asciidoctorExtensions 'org.springframework.restdocs:spring-restdocs-asciidoctor'
// restdocs에서 MockMvc를 사용할 때 사용하는 의존성
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
implementation group: 'org.springframework.restdocs', name: 'spring-restdocs-core'
//AWS S3 의존성 추가
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-aws', version: '2.2.1.RELEASE'
//mariadb 의존성 추가
implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client'
testCompileOnly 'org.projectlombok:lombok' // 테스트 의존성 추가
testAnnotationProcessor 'org.projectlombok:lombok' // 테스트 의존성 추가
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
ext {
snippetsDir = file('build/generated-snippets')
}
test {
useJUnitPlatform()
outputs.dir snippetsDir // 선언한 디렉토리에 생성
finalizedBy 'jacocoTestReport'
}
// ext에서 정의한 경로에 스니펫을 넣어준뒤 테스트를 진행한다.
asciidoctor {
configurations "asciidoctorExtensions"
inputs.dir snippetsDir
dependsOn test
}
task copyDocument(type: Copy) {
dependsOn asciidoctor
from file("build/docs/asciidoc")
into file("src/main/resources/static/docs")
}
//기존에 파일이 있다면 제거한다.
asciidoctor.doFirst {
println("---------------- delete present asciidoctor.")
delete file('src/main/resources/static/docs')
}
asciidoctor.doLast { // 8
println("---------------- asciidoctor is deleted!")
}
//Jar로 빌드가 되면서 실제 배포시 생성된 명세 html파일의 경로를 찾아 BOOT-INF/classes/static/docs 맵핑
bootJar {
dependsOn asciidoctor
from ("${asciidoctor.outputDir}") {
into 'static/docs'
}
}
build {
dependsOn('copyDocument')
}
jar {
// springboot v2.5 이상부터는 빌드 시 plain 아카이브가 생성된다.
// docker로 배포하기위해서는 하나의 jar만 필요함으로 plan.jar를 제거하기위한 설정
enabled = false
}
jacocoTestReport {
reports {
html.enabled true
csv.enabled false
xml.enabled true
}
afterEvaluate {
classDirectories.setFrom(
files(classDirectories.files.collect {
fileTree(dir: it, excludes: [
'**/*Application*',
'**/domain/*',
'**/entity/*',
'**/dto/*',
'**/config/*',
'**/utils/*'
])
})
)
}
finalizedBy 'jacocoTestCoverageVerification'
}
jacocoTestCoverageVerification {
violationRules {
rule {
enabled = true
element = 'CLASS'
// includes = []
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.50
}
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.70
}
excludes = [
"**.*Application",
"**.config.*",
"**.domain.*",
'**.global.utils.image.*',
'**.global.exception.*',
'**.web.dto.*',
]
}
}
}