-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
169 lines (141 loc) · 3.82 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
165
166
167
168
169
plugins {
id 'java'
id 'org.springframework.boot' version '2.7.5'
id 'io.spring.dependency-management' version '1.1.4'
//[spring rest docs] asciidocotr 플러그인
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'jacoco'
}
group = 'com.flab'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '11'
}
configurations {
asciidoctorExt // asciidoctor 확장 기능 사용하기 위한 설정
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
runtimeOnly 'mysql:mysql-connector-java'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
//security
implementation 'org.springframework.boot:spring-boot-starter-security'
testImplementation 'org.springframework.security:spring-security-test'
// jwt
implementation 'io.jsonwebtoken:jjwt:0.9.1'
/**
* Test Implementation
*/
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.hamcrest:hamcrest:2.2'
// REST Docs Implementation 추가
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'
//cache
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-cache'
}
// sinppetsDir 추가
ext {
snippetsDir = file('build/genertated-snippets')
}
// test 할 때 snippestDir에 생성된 응답을 asciidoctor로 변환하여 .adoc 파일 생성
tasks.named('test') {
outputs.dir snippetsDir
useJUnitPlatform()
}
//asciidoctor를 사용하기 위해서 asciidoctor task에 asciidoctorExtensions 설정
tasks.named('asciidoctor') {
inputs.dir snippetsDir
configurations 'asciidoctorExt'
sources{
include("**/index.adoc")
}
baseDirFollowsSourceFile()
dependsOn test // 테스트 이후에 실행
}
asciidoctor.doFirst { // asciidoctor Task가 수행될 때 가장 먼저 수행 , 기존파일 삭제
delete file('src/main/resources/static/docs')
}
//asciidoctor task 실행시 생성된 html 파일을 src/main/resources/static/docs 디렉토리에 카피
task copyDocument(type: Copy) {
dependsOn asciidoctor
from file("build/docs/asciidoc")
into file("src/main/resources/static/docs")
}
//빌드 전 copyDocumnet task 실행
build {
dependsOn copyDocument
}
bootJar {
dependsOn asciidoctor
copy {
from("${asciidoctor.outputDir}")
into 'src/main/resources/static/docs'
}
}
// JaCoCo 설정 추가
jacoco {
toolVersion = "0.8.7"
}
jacocoTestReport {
dependsOn test
reports {
csv.required = false
xml.required = false
html.required = true
html.destination file("jacoco/jacocoHtml")
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, excludes: [
'**/*Dto*',
'**/*Request*',
'**/*Response*',
'**/*Filter*',
'**/*Config*',
'**/*Provider*',
'**/*TessApplication*'
])
}))
}
}
jacocoTestCoverageVerification {
// 커버리지의 범위와 퍼센테이지를 설정합니다.
violationRules {
rule {
element = 'CLASS' // class 단위로 룰을 체크합니다.
// 제외할 클래스들
excludes = [
'**.*Dto*',
'**.*Request*',
'**.*Response*',
'**.*Filter*',
'**.*Config*',
'**.*Provider*',
'**.*TessApplication*'
]
// 브랜치 커버리지의 최소값을 설정합니다.
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.70
}
}
}
}
tasks.named('test') {
finalizedBy jacocoTestReport // 테스트 후에 커버리지 리포트를 생성하도록 설정
}
tasks.named('check') {
dependsOn jacocoTestCoverageVerification
}