전체 서비스 빌드 설정 업데이트 및 kos-mock 데이터 동기화

This commit is contained in:
hiondal
2025-09-11 18:37:56 +09:00
parent fb0c5da973
commit 0f1e22c5dc
8 changed files with 41 additions and 287 deletions
-45
View File
@@ -44,52 +44,7 @@ dependencyManagement {
} }
} }
// 추가 테스트 설정 (루트에서 기본 설정됨)
tasks.named('test') {
systemProperty 'spring.profiles.active', 'test'
}
// JAR 파일명 설정
jar {
archiveBaseName = 'api-gateway'
enabled = false
}
bootJar { bootJar {
archiveFileName = 'api-gateway.jar' archiveFileName = 'api-gateway.jar'
// 빌드 정보 추가
manifest {
attributes(
'Implementation-Title': 'PhoneBill API Gateway',
'Implementation-Version': "${version}",
'Built-By': System.getProperty('user.name'),
'Built-JDK': System.getProperty('java.version'),
'Build-Time': new Date().format('yyyy-MM-dd HH:mm:ss')
)
}
}
// 개발 환경 실행 설정
if (project.hasProperty('dev')) {
bootRun {
systemProperty 'spring.profiles.active', 'dev'
jvmArgs = ['-Dspring.devtools.restart.enabled=true']
}
} }
// 프로덕션 환경 실행 설정
if (project.hasProperty('prod')) {
bootRun {
systemProperty 'spring.profiles.active', 'prod'
jvmArgs = [
'-server',
'-Xms512m',
'-Xmx1024m',
'-XX:+UseG1GC',
'-XX:G1HeapRegionSize=16m',
'-XX:+UseStringDeduplication',
'-XX:+OptimizeStringConcat'
]
}
}
-59
View File
@@ -1,10 +1,6 @@
// bill-service 모듈 // bill-service 모듈
// 루트 build.gradle의 subprojects 블록에서 공통 설정 적용됨 // 루트 build.gradle의 subprojects 블록에서 공통 설정 적용됨
plugins {
id 'jacoco'
}
dependencies { dependencies {
// Database (bill service specific) // Database (bill service specific)
runtimeOnly 'org.postgresql:postgresql' runtimeOnly 'org.postgresql:postgresql'
@@ -36,62 +32,7 @@ dependencies {
testImplementation 'com.github.tomakehurst:wiremock-jre8:2.35.0' testImplementation 'com.github.tomakehurst:wiremock-jre8:2.35.0'
} }
tasks.named('test') {
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test
reports {
xml.required = true
csv.required = false
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
}
jacoco {
toolVersion = "0.8.8"
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.80
}
}
}
}
springBoot {
buildInfo()
}
// 환경별 실행 프로필 설정
task runDev(type: JavaExec, dependsOn: 'classes') {
group = 'application'
description = 'Run the application with dev profile'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'com.phonebill.bill.BillServiceApplication'
systemProperty 'spring.profiles.active', 'dev'
}
task runProd(type: JavaExec, dependsOn: 'classes') {
group = 'application'
description = 'Run the application with prod profile'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'com.phonebill.bill.BillServiceApplication'
systemProperty 'spring.profiles.active', 'prod'
}
// JAR 파일명 설정
jar {
enabled = false
archiveBaseName = 'bill-service'
}
bootJar { bootJar {
archiveFileName = 'bill-service.jar' archiveFileName = 'bill-service.jar'
enabled = true enabled = true
archiveClassifier = ''
} }
+40 -1
View File
@@ -3,6 +3,8 @@ plugins {
id 'org.springframework.boot' version '3.3.0' apply false id 'org.springframework.boot' version '3.3.0' apply false
id 'io.spring.dependency-management' version '1.1.6' apply false id 'io.spring.dependency-management' version '1.1.6' apply false
id 'io.freefair.lombok' version '8.10' apply false id 'io.freefair.lombok' version '8.10' apply false
id "org.sonarqube" version "5.0.0.4638" apply false
} }
group = 'com.unicorn.phonebill' group = 'com.unicorn.phonebill'
@@ -18,7 +20,7 @@ allprojects {
subprojects { subprojects {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'io.freefair.lombok' apply plugin: 'io.freefair.lombok'
if (it.name == 'common') { if (it.name == 'common') {
apply plugin: 'io.spring.dependency-management' apply plugin: 'io.spring.dependency-management'
} else { } else {
@@ -26,6 +28,13 @@ subprojects {
apply plugin: 'io.spring.dependency-management' apply plugin: 'io.spring.dependency-management'
} }
apply plugin: 'org.sonarqube'
apply plugin: 'jacoco' // 서브 프로젝트에 JaCoCo 플러그인 적용
jacoco {
toolVersion = "0.8.11" // JaCoCo 최신 버전 사용
}
java { java {
toolchain { toolchain {
languageVersion = JavaLanguageVersion.of(21) languageVersion = JavaLanguageVersion.of(21)
@@ -53,6 +62,36 @@ subprojects {
openaiVersion = '0.18.2' openaiVersion = '0.18.2'
feignJacksonVersion = '13.1' feignJacksonVersion = '13.1'
} }
test {
useJUnitPlatform()
include '**/*Test.class'
testLogging {
events "passed", "skipped", "failed"
}
finalizedBy jacocoTestReport // 테스트 후 JaCoCo 리포트 생성
}
jacocoTestReport {
dependsOn test
reports {
xml.required = true // SonarQube 분석을 위해 XML 형식 필요
csv.required = false
html.required = true
html.outputLocation = layout.buildDirectory.dir("jacocoHtml").get().asFile
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"**/config/**", // 설정 클래스 제외
"**/entity/**", // 엔티티 클래스 제외
"**/dto/**", // DTO 클래스 제외
"**/*Application.class", // 메인 애플리케이션 클래스 제외
"**/exception/**" // 예외 클래스 제외
])
}))
}
}
} }
// Configure only service modules (exclude common and api-gateway) // Configure only service modules (exclude common and api-gateway)
-17
View File
@@ -1,12 +1,6 @@
// kos-mock 모듈 // kos-mock 모듈
// 루트 build.gradle의 subprojects 블록에서 공통 설정 적용됨 // 루트 build.gradle의 subprojects 블록에서 공통 설정 적용됨
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
dependencies { dependencies {
// Spring Boot // Spring Boot
implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-web'
@@ -41,17 +35,6 @@ dependencies {
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
} }
tasks.named('test') {
useJUnitPlatform()
}
// JAR 파일 이름 설정 (다른 모듈에서 참조할 수 있도록 enabled = true)
jar {
archiveBaseName = 'kos-mock-service'
archiveVersion = version
enabled = true
}
bootJar { bootJar {
archiveFileName = 'kos-mock.jar' archiveFileName = 'kos-mock.jar'
} }
Binary file not shown.
@@ -82,5 +82,3 @@ springdoc:
operations-sorter: alpha operations-sorter: alpha
show-actuator: true show-actuator: true
paths-to-exclude: /actuator/** paths-to-exclude: /actuator/**
cors:
allowed-origins: "http://localhost:3000,http://phonebill.20.214.196.128.nip.io,http://phonebill-front.20.214.196.128.nip.io"
+1 -153
View File
@@ -30,160 +30,8 @@ dependencies {
testImplementation 'io.github.resilience4j:resilience4j-test:2.1.0' testImplementation 'io.github.resilience4j:resilience4j-test:2.1.0'
} }
dependencyManagement {
imports {
mavenBom 'org.testcontainers:testcontainers-bom:1.19.1'
}
}
tasks.named('test') {
// Test 환경 설정
systemProperty 'spring.profiles.active', 'test'
// 병렬 실행 설정
maxParallelForks = Runtime.runtime.availableProcessors()
// 메모리 설정
minHeapSize = "512m"
maxHeapSize = "2048m"
// Test 결과 리포트
testLogging {
events "passed", "skipped", "failed"
exceptionFormat = 'full'
}
// Coverage 설정
finalizedBy jacocoTestReport
}
// Jacoco Test Coverage
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.8.10"
}
jacocoTestReport {
dependsOn test
reports {
xml.required = true
csv.required = false
html.required = true
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'**/dto/**',
'**/config/**',
'**/exception/**',
'**/*Application.*'
])
}))
}
}
jacocoTestCoverageVerification {
dependsOn jacocoTestReport
violationRules {
rule {
limit {
minimum = 0.80 // 80% 커버리지 목표
}
}
}
}
// Spring Boot Plugin 설정
springBoot {
buildInfo()
}
// JAR 설정 // JAR 설정
jar {
enabled = false
archiveClassifier = ''
}
bootJar { bootJar {
enabled = true enabled = true
archiveClassifier = '' archiveFileName = "product-service.jar"
archiveFileName = "${project.name}.jar"
// Build 정보 포함
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': 'MVNO Corp',
'Built-By': System.getProperty('user.name'),
'Build-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ss.SSSZ"),
'Created-By': "${System.getProperty('java.version')} (${System.getProperty('java.vendor')})",
'Build-Jdk': "${System.getProperty('java.version')}",
'Build-OS': "${System.getProperty('os.name')} ${System.getProperty('os.arch')} ${System.getProperty('os.version')}"
)
}
} }
// 개발 환경 설정
if (project.hasProperty('dev')) {
bootRun {
args = ['--spring.profiles.active=dev']
systemProperty 'spring.devtools.restart.enabled', 'true'
systemProperty 'spring.devtools.livereload.enabled', 'true'
}
}
// Production 빌드 설정
if (project.hasProperty('prod')) {
bootJar {
archiveFileName = "${project.name}-${project.version}-prod.jar"
}
}
// Docker 빌드를 위한 태스크
task copyJar(type: Copy, dependsOn: bootJar) {
from layout.buildDirectory.file("libs/${bootJar.archiveFileName.get()}")
into layout.buildDirectory.dir("docker")
rename { String fileName ->
fileName.replace(bootJar.archiveFileName.get(), "app.jar")
}
}
// 정적 분석 도구 설정 (추후 확장 가능)
task checkstyle(type: Checkstyle) {
configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")
source 'src/main/java'
include '**/*.java'
exclude '**/generated/**'
classpath = files()
ignoreFailures = true
}
// Clean 확장
clean {
delete 'logs'
delete 'build/docker'
}
// 컴파일 옵션
compileJava {
options.encoding = 'UTF-8'
options.compilerArgs += [
'-Xlint:all',
'-Xlint:-processing',
'-Werror'
]
}
compileTestJava {
options.encoding = 'UTF-8'
options.compilerArgs += [
'-Xlint:all',
'-Xlint:-processing'
]
}
-10
View File
@@ -26,16 +26,6 @@ dependencies {
// 추가 테스트 설정 (루트에서 기본 설정됨) // 추가 테스트 설정 (루트에서 기본 설정됨)
// JAR 파일명 설정 // JAR 파일명 설정
jar {
archiveBaseName = 'user-service'
enabled = false
}
bootJar { bootJar {
archiveFileName = 'user-service.jar' archiveFileName = 'user-service.jar'
} }
// Spring Boot 실행 설정
springBoot {
mainClass = 'com.phonebill.user.UserServiceApplication'
}