-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
218 lines (182 loc) · 5.91 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
buildscript {
ext {
queryDslVersion = "5.0.0"
}
}
plugins {
id 'java'
id 'org.springframework.boot' version '3.1.5'
id 'io.spring.dependency-management' version '1.1.3'
//RestDocs
id "org.asciidoctor.jvm.convert" version "3.3.2"
id 'jacoco'
id "org.sonarqube" version "4.4.1.3373"
}
sonar {
properties {
property "sonar.projectKey", "Anifriends_Anifriends-Backend"
property "sonar.organization", "anifriends"
property "sonar.host.url", "https://sonarcloud.io"
}
}
group = 'com.clova'
version = '0.0.1-SNAPSHOT'
configurations {
//RestDocs
asciidoctorExt
}
java {
sourceCompatibility = '17'
}
// plain jar 파일을 생성하지 않는다.
jar {
enabled = false
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.projectlombok:lombok:1.18.22'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// DB
runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
//RestDocs
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
//querydsl
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"
//jwt
implementation 'io.jsonwebtoken:jjwt-api:0.12.3'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.3'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.3'
//test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.awaitility:awaitility'
testImplementation "org.testcontainers:testcontainers:1.19.0"
testImplementation "org.testcontainers:junit-jupiter:1.19.0"
// S3 AWS
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-aws', version: '2.2.6.RELEASE'
testImplementation 'io.findify:s3mock_2.13:0.2.6'
// Websocket
implementation 'org.springframework.boot:spring-boot-starter-websocket'
// Monitoring
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'
testImplementation 'org.awaitility:awaitility:4.2.0'
}
tasks.named('test') {
useJUnitPlatform()
finalizedBy jacocoTestReport // 테스트 실행 후 항상 report가 생성됩니다.
}
//RestDocs start
ext {
snippetsDir = file('build/generated-snippets')
}
test {
outputs.dir snippetsDir
}
asciidoctor.doFirst {
delete file('src/main/resources/static/docs')
}
asciidoctor {
inputs.dir snippetsDir
configurations 'asciidoctorExt'
dependsOn test
}
bootJar {
dependsOn asciidoctor
from("${asciidoctor.outputDir}/html5") {
into 'static/docs'
}
}
tasks.register('copyDocument', Copy) {
dependsOn asciidoctor
from file("build/docs/asciidoc")
into file("src/main/resources/static/docs")
}
build {
dependsOn copyDocument
}
//RestDocs end
// Querydsl 설정부
def generated = 'src/main/generated'
// querydsl QClass 파일 생성 위치를 지정
tasks.withType(JavaCompile) {
options.getGeneratedSourceOutputDirectory().set(file(generated))
}
// java source set 에 querydsl QClass 위치 추가
sourceSets {
main.java.srcDirs += [generated]
}
// gradle clean 시에 QClass 디렉토리 삭제
clean {
delete file(generated)
}
//jacoco start
private excludedClassFilesForReport(classDirectories) {
classDirectories.setFrom(
files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"**/Q*",
"**/*Application*",
"**/*Config*",
"**/*Response*",
"**/*Request*",
"**/exception/**",
"**/Mock**",
"**/aspect/**"
])
})
)
}
jacoco {
toolVersion = "0.8.9"
}
jacocoTestReport {
dependsOn test // report를 생성하기 전에 테스트를 실행해야합니다.
reports {
xml.required = true
csv.required = false
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
excludedClassFilesForReport(classDirectories)
finalizedBy jacocoTestCoverageVerification // 테스트 실행 후 항상 테스트 커버리지 검증을 실행합니다.
}
jacocoTestCoverageVerification { // 코드 커버리지를 검증합니다. 규칙을 만족하지 못하면 빌드는 실패합니다.
excludedClassFilesForReport(classDirectories)
violationRules {
rule { // 규칙을 지정합니다.
enabled = true
element = 'CLASS' // 클래스 단위로 규칙을 체크합니다.
// 브랜치 커버리지를 최소 70% 만족시켜야 합니다.
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.70
}
// 라인 커버리지를 최소 70% 만족시켜야 합니다.
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.70
}
}
}
}
//jacoco end