-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
219 lines (177 loc) ยท 6.02 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
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
plugins {
id 'org.springframework.boot' version '2.4.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
id 'java'
id 'jacoco'
id "org.sonarqube" version "3.0"
}
group = 'com.tomasfriends'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
// JPA, Mysql
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
compile 'mysql:mysql-connector-java'
// Swagger
implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
// https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt
implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
// queryDSL
implementation group: 'com.querydsl', name: 'querydsl-apt', version: '4.1.4'
implementation group: 'com.querydsl', name: 'querydsl-jpa', version: '4.1.4'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'com.google.code.gson:gson'
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.12'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
implementation 'org.springframework.boot:spring-boot-starter-security'
}
test {
jacoco {
destinationFile = file("$buildDir/jacoco/jacoco.exec")
}
useJUnitPlatform()
finalizedBy 'jacocoTestReport'
}
jacoco {
// JaCoCo ๋ฒ์
// ๋ฒ์ 0.8.5 ๋ก ํ๋ค๊ฐ ํ๋ฃจ์ข
์ผ ์ฝ์งํจ. ์ต์ ์ผ๋ก ์ ์ง.
toolVersion = '0.8.6'
// ํ
์คํธ๊ฒฐ๊ณผ ๋ฆฌํฌํธ๋ฅผ ์ ์ฅํ ๊ฒฝ๋ก ๋ณ๊ฒฝ
// default๋ "${project.reporting.baseDir}/jacoco"
// reportsDir = file("$buildDir/customJacocoReportDir")
}
jacocoTestReport {
reports {
// ์ํ๋ ๋ฆฌํฌํธ๋ฅผ ์ผ๊ณ ๋ ์ ์๋ค.
html.enabled true
xml.enabled true
csv.enabled false
// ๊ฐ ๋ฆฌํฌํธ ํ์
๋ง๋ค ๋ฆฌํฌํธ ์ ์ฅ ๊ฒฝ๋ก๋ฅผ ์ค์ ํ ์ ์๋ค.
// html.destination file("$buildDir/jacocoHtml")
// xml.destination file("$buildDir/jacoco.xml")
}
def Qdomains = []
def Exceptions = ['**/exceptions/**']
def Dtos = ['**/dto/**']
for (qPattern in '**/QA'..'**/QZ') {
Qdomains.add(qPattern + '*')
}
// ์ฌ๊ธฐ๋ถํฐ
afterEvaluate {
classDirectories.setFrom(
files(classDirectories.files.collect {
fileTree(dir: it, excludes: [] + Qdomains + Exceptions + Dtos)
})
)
}
// test task ๋ฅผ ์คํํ ๋ ๋ง๋ค ์๋์ผ๋ก jacoco task ์ ์คํ๋๊ฒ ํ๋ค.
// ํ
์คํธ๋ง ํ๋ ค ํ๋๋ฐ ๋ฆฌํฌํธ๋ ์คํ๋ ์ ์์ผ๋ ๊ฐ์ธ ์ทจํฅ๋๋ก ๋ฃ๊ณ ๋นผ์.
finalizedBy 'jacocoTestCoverageVerification'
}
jacocoTestCoverageVerification {
def Qdomains = []
for (qPattern in '**/QA'..'**/QZ') { // qPattern = '**/QA', '**/QB', ... '*.QZ'
Qdomains.add(qPattern + '*')
}
violationRules {
rule {
// 'element'๊ฐ ์์ผ๋ฉด ํ๋ก์ ํธ์ ์ ์ฒด ํ์ผ์ ํฉ์น ๊ฐ์ ๊ธฐ์ค์ผ๋ก ํ๋ค.
limit {
// 'counter'๋ฅผ ์ง์ ํ์ง ์์ผ๋ฉด default๋ 'INSTRUCTION'
// 'value'๋ฅผ ์ง์ ํ์ง ์์ผ๋ฉด default๋ 'COVEREDRATIO'
minimum = 0.00
}
}
rule {
enabled = true
element = 'CLASS'
// ์ปค๋ฒ๋ฆฌ์ง ์ฒดํฌ๋ฅผ ์ ์ธํ ํด๋์ค๋ค
excludes = ["*.*Application", "*.*Dto"] + Qdomains
}
rule {
// ๋ฃฐ์ ๊ฐ๋จํ ์ผ๊ณ ๋ ์ ์๋ค.
enabled = false
// ๋ฃฐ์ ์ฒดํฌํ ๋จ์๋ ํด๋์ค ๋จ์
element = 'CLASS'
// ๋ธ๋์น ์ปค๋ฒ๋ฆฌ์ง๋ฅผ ์ต์ํ 60% ๋ง์กฑ์์ผ์ผ ํ๋ค.
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.60
}
// ๋ผ์ธ ์ปค๋ฒ๋ฆฌ์ง๋ฅผ ์ต์ํ 60% ๋ง์กฑ์์ผ์ผ ํ๋ค.
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.60
}
// ๋น ์ค์ ์ ์ธํ ์ฝ๋์ ๋ผ์ธ์๋ฅผ ์ต๋ 200๋ผ์ธ์ผ๋ก ์ ํํ๋ค.
limit {
counter = 'LINE'
value = 'TOTALCOUNT'
maximum = 200
// maximum = 8
}
// ์ปค๋ฒ๋ฆฌ์ง ์ฒดํฌ๋ฅผ ์ ์ธํ ํด๋์ค๋ค
excludes = ["*.Q*", "*.*Application", "*.dto", "*.dto.*", "*.config.*", "*.security.*", "*.exceptions.*"] + Qdomains
}
}
}
task testCoverage(type: Test) {
// task ์ง์ ์ผ๋ก
// ./gradlew --console verbose test jacocoTestReport jacocoTestCoverageVerification ์ ๊ฐ์ ๊ธด ๋ช
๋ น์
// ./gradlew testCoverage ๋ก ํ๊บผ๋ฒ์ ์์๋๋ก ์งํ ๊ฐ๋ฅ
group 'verification'
description 'Runs the unit tests with coverage'
dependsOn(':test',
':jacocoTestReport',
':jacocoTestCoverageVerification')
tasks['jacocoTestReport'].mustRunAfter(tasks['test'])
tasks['jacocoTestCoverageVerification'].mustRunAfter(tasks['jacocoTestReport'])
}
sonarqube {
properties {
property "sonar.projectKey", "bansikee_server"
property "sonar.host.url", "http://34.64.89.2:8080"
property "sonar.login", "9c1885722133b2778e5ba408584605450e6e2163"
property "sonar.source", "src"
property "sonar.language", "java"
property "sonar.sourceEncoding", "UTF-8"
property "sonar.coverage.jacoco.xmlReportPaths", "${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
property 'sonar.java.binaries', '${buildDir}/classes'
property 'sonar.exclusions', '**/test/**, **/Q*.java, **/*Doc*.java, **/resources/**, **/dto/**, **/config/**, **/common/**, **/component/**'
}
}
// querydsl
def querydslDir = "$buildDir/generated/querydsl"
querydsl {
jpa = true
querydslSourcesDir = querydslDir
}
sourceSets {
main.java.srcDir querydslDir
}
configurations {
querydsl.extendsFrom compileClasspath
}
compileQuerydsl {
options.annotationProcessorPath = configurations.querydsl
}
// querydsl