-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
241 lines (195 loc) · 6.48 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
plugins {
id "io.spring.dependency-management" version '1.0.11.RELEASE'
id 'org.springframework.boot' version '2.5.6'
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'java'
id 'jacoco'
id "org.sonarqube" version "3.3"
id 'com.google.cloud.tools.jib' version '3.1.4'
}
group = 'com.prgrms'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
asciidoctorExtensions
compileOnly {
extendsFrom annotationProcessor
}
}
ext {
set('snippetsDir', file("build/generated-snippets"))
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
runtimeOnly 'com.h2database:h2'
runtimeOnly 'mysql:mysql-connector-java'
// lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
//jwt 의존성
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// Rest Assured
testImplementation 'io.rest-assured:rest-assured:4.4.0'
// rest-docs
asciidoctorExtensions 'org.springframework.restdocs:spring-restdocs-asciidoctor'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
// for swagger
implementation 'io.springfox:springfox-boot-starter:3.0.0'
implementation "com.querydsl:querydsl-jpa"
implementation "com.querydsl:querydsl-core"
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jpa"
// querydsl JPAAnnotationProcessor 사용 지정
annotationProcessor "jakarta.persistence:jakarta.persistence-api:2.2.3"
annotationProcessor "jakarta.annotation:jakarta.annotation-api:1.3.5"
}
sonarqube {
properties {
property "sonar.projectKey", "price-offer_offer-be"
property "sonar.organization", "price-offer-sonar-cloud-key"
property "sonar.host.url", "https://sonarcloud.io"
property 'sonar.coverage.jacoco.xmlReportPaths', "$buildDir/jacoco.xml"
}
}
tasks.named('test') {
outputs.dir snippetsDir
useJUnitPlatform()
finalizedBy 'jacocoTestReport'
}
tasks.named('asciidoctor') {
configurations 'asciidoctorExtensions'
sources {
include("**/index.adoc", "**/common/*.adoc")
}
baseDirFollowsSourceFile()
inputs.dir snippetsDir
dependsOn test
}
asciidoctor.doFirst {
delete file('src/main/resources/static/docs')
}
task createDocument(type: Copy) {
dependsOn asciidoctor
from file("build/docs/asciidoc")
into file("src/main/resources/static")
}
task displaceDocument(type: Copy) {
dependsOn asciidoctor
from("${asciidoctor.outputDir}")
into("build/resources/main/static")
}
bootJar {
dependsOn createDocument
dependsOn displaceDocument
}
//processResources.dependsOn('copySecret')
//
//task copySecret(type: Copy) {
// from '../offer-be/be-submodule'
// into 'src/main/resources'
//}
// querydsl 적용
def generated = 'src/main/generated'
sourceSets {
main.java.srcDirs += [generated]
}
tasks.withType(JavaCompile) {
options.annotationProcessorGeneratedSourcesDirectory = file(generated)
}
clean.doLast {
file(generated).deleteDir()
}
//// Jacoco 플러그인 설정
//jacoco {
// toolVersion = '0.8.7'
// // reportsDir = ${project.reporting.baseDir}/jacoco - 따로 설정해 주지 않을 경우 기본 경로
//}
// jacocoTestReport 설정
jacocoTestReport {
reports {
html.enabled true // 로컬에서 확인용으로 html 리포트 파일 생성
// html.destination file("$buildDir/reports/test/jacocoTestReport.html")
xml.enabled true // SonarCloud로 전송하기 위해 XML 리포트 생성
xml.destination file("$buildDir/jacoco.xml")
csv.enabled false // csv는 생성하지 않음
}
def Qdomains = []
for (qPattern in '**/QA'..'**/QZ') { // qPattern = '*.QA', '*.QB', ... '*.QZ'
Qdomains.add(qPattern + '*')
}
afterEvaluate {
classDirectories.setFrom(
files(classDirectories.files.collect {
fileTree(dir: it, excludes: [
'**/*Application*',
'**/*Request*',
'**/*Response*',
'**/*OAuthClient*',
'**/*Interceptor*',
'**/*Exception*',
] + Qdomains)
})
)
}
// 코드 커버리지 기준을 만족해야지 build 성공
finalizedBy 'jacocoTestCoverageVerification'
}
// jacocoTestCoverageVerification 설정
jacocoTestCoverageVerification {
def Qdomains = []
for (qPattern in '*.QA'..'*.QZ') {
Qdomains.add(qPattern + '*')
}
violationRules {
rule {
enabled = true // 이 rule을 적용할 것이다.
element = 'CLASS'
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.00 // TODO: 브랜치 커버리지 최소 50%
}
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.00 // TODO: 라인 커버리지 최소한 80%
}
excludes = [
'**.*Application*',
'**.*Request*',
'**.*Response*',
'**.*OAuthClient*',
'**.*Interceptor*',
'**.*Exception*',
] + Qdomains
}
}
}
jib {
from {
image = 'adoptopenjdk/openjdk11:alpine-jre'
}
container {
entrypoint = ['java', '-jar', 'offer-0.0.1-SNAPSHOT.jar']
jvmFlags = [' -Xms512m', '-Xmx512m', '-Xdebug', '-XshowSettings: vm', '-XX: +UnlockExperimentalVMOptions', '-XX:+UseContainerSupport']
ports = ['7070']
environment = [SPRING_OUTPUT_ANSI_ENABLED: "ALWAYS"]
labels = [Iversion: project.version, name: project.name, group: project.group]
format = 'Docker'
}
extraDirectories {
paths {
path {
from = file('build/libs')
}
}
}
}