-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
230 lines (198 loc) Β· 7.91 KB
/
build.gradle
File metadata and controls
230 lines (198 loc) Β· 7.91 KB
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
plugins {
id 'java'
id 'org.springframework.boot' version '3.4.0'
id 'io.spring.dependency-management' version '1.1.6'
id 'checkstyle'
id 'jacoco'
id 'com.diffplug.spotless' version '6.25.0'
id 'org.sonarqube' version '7.2.0.6526'
}
group = 'com.project'
version = '0.0.1-SNAPSHOT'
// ============================================================================
// Coverage Exclusion Patterns (κ³΅ν΅ μ μΈ ν¨ν΄)
// ============================================================================
def coverageExcludePackages = [
'**', // TODO: 1μ°¨ κ°λ° μλ£ ν μ κ±°
'**/config/**', // Config ν΄λμ€ μ μΈ
'**/exception/**', // Exception ν΄λμ€ μ μΈ
'**/dto/**', // DTO ν΄λμ€ μ μΈ
]
// JaCoCoμ© μ μΈ ν¨ν΄ (ν΄λμ€ νμΌ)
def jacocoCoverageExcludes = coverageExcludePackages + ['**/*Application.class']
// Sonarμ© μ μΈ ν¨ν΄ (μμ€ νμΌ)
def sonarCoverageExcludes = coverageExcludePackages.collect { it + '/*.java' } + ['**/Application.java']
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
// OpenTelemetry BOM for consistent versions
dependencyManagement {
imports {
mavenBom 'io.opentelemetry:opentelemetry-bom:1.44.1'
mavenBom 'io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:2.11.0-alpha'
}
}
dependencies {
// Spring Boot
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
// Monitoring & Observability - OpenTelemetry (traces, logs)
implementation 'io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter'
implementation 'io.opentelemetry.instrumentation:opentelemetry-logback-appender-1.0'
// Micrometer - Prometheus (local scraping) + OTLP (push to Alloy)
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation 'io.micrometer:micrometer-registry-otlp'
implementation 'com.google.protobuf:protobuf-java:3.25.5'
// Structured logging
implementation 'net.logstash.logback:logstash-logback-encoder:7.4'
// Database
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
runtimeOnly 'com.mysql:mysql-connector-j'
implementation 'org.springframework.kafka:spring-kafka'
implementation 'com.github.da-bom:lib-kafka:v1.0.1'
// Flyway
implementation 'org.flywaydb:flyway-core'
implementation 'org.flywaydb:flyway-mysql'
// QueryDSL
implementation 'com.querydsl:querydsl-jpa:5.1.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:5.1.0:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"
// Swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.7.0'
// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// jwt
implementation "io.jsonwebtoken:jjwt-api:0.11.2"
runtimeOnly "io.jsonwebtoken:jjwt-impl:0.11.2"
runtimeOnly "io.jsonwebtoken:jjwt-jackson:0.11.2"
//BCrypt
implementation 'org.mindrot:jbcrypt:0.4'
// AWS SDK v2 - S3 (R2 compatible)
implementation platform('software.amazon.awssdk:bom:2.25.70')
implementation 'software.amazon.awssdk:s3'
// Test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation 'org.springframework.kafka:spring-kafka-test'
testRuntimeOnly 'com.h2database:h2'
}
// ============================================================================
// bootRun (.env νμΌμμ νκ²½λ³μ λ‘λ©)
// ============================================================================
bootRun {
def envFile = rootProject.file('.env')
if (envFile.exists()) {
envFile.readLines().each { line ->
line = line.trim()
if (line && !line.startsWith('#') && line.contains('=')) {
def (key, value) = line.split('=', 2)
environment key.trim(), value.trim()
}
}
}
}
// ============================================================================
// Test
// ============================================================================
tasks.named('test') {
useJUnitPlatform()
finalizedBy jacocoTestReport, jacocoTestCoverageVerification
}
// ============================================================================
// JaCoCo (Code Coverage)
// ============================================================================
jacoco {
toolVersion = '0.8.12'
}
jacocoTestReport {
dependsOn test
reports {
xml.required = true
html.required = true
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: jacocoCoverageExcludes)
}))
}
}
jacocoTestCoverageVerification {
dependsOn jacocoTestReport
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: jacocoCoverageExcludes)
}))
}
violationRules {
rule {
limit {
minimum = 0.0
}
}
}
// κ²μ¬ν ν΄λμ€κ° μμΌλ©΄ 컀λ²λ¦¬μ§ κ²μ¦ 건λλ°κΈ°
doFirst {
def hasClasses = classDirectories.files.any { dir ->
dir.exists() && fileTree(dir: dir, exclude: jacocoCoverageExcludes).files.size() > 0
}
if (!hasClasses) {
println "No classes to verify coverage. Skipping jacocoTestCoverageVerification."
throw new StopExecutionException()
}
}
}
// ============================================================================
// Checkstyle (Code Style) - Naver Conventions
// ============================================================================
checkstyle {
toolVersion = '10.21.4'
configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")
configDirectory = file("${rootDir}/config/checkstyle")
ignoreFailures = false
maxWarnings = 0
}
// ============================================================================
// Spotless (Code Formatting) - 4-space indentation, Naver import order
// ============================================================================
spotless {
java {
target 'src/*/java/**/*.java'
googleJavaFormat().aosp().reflowLongStrings()
// Naver convention import order: java -> javax -> jakarta -> org -> net -> com -> others -> lombok
importOrder('java', 'javax', 'jakarta', 'org', 'net', 'com', '', 'lombok')
trimTrailingWhitespace()
endWithNewline()
}
}
// ============================================================================
// SonarQube (Self-Hosted)
// ============================================================================
sonar {
properties {
property 'sonar.projectKey', 'dabom-api-core'
property 'sonar.projectName', 'dabom-api-core'
// Java λΆμμ μν λ°μ΄λ리 κ²½λ‘
property 'sonar.java.binaries', 'build/classes/java/main'
property 'sonar.java.libraries', "${System.getProperty('user.home')}/.gradle/caches/**/modules-*/files-*/**/*.jar"
// JaCoCo 컀λ²λ¦¬μ§
property 'sonar.java.coveragePlugin', 'jacoco'
property 'sonar.coverage.jacoco.xmlReportPaths', 'build/reports/jacoco/test/jacocoTestReport.xml'
property 'sonar.coverage.exclusions', sonarCoverageExcludes.join(',')
}
}