diff --git a/api-gateway/build.gradle b/api-gateway/build.gradle index 9c13fbd..4728b86 100644 --- a/api-gateway/build.gradle +++ b/api-gateway/build.gradle @@ -44,52 +44,7 @@ dependencyManagement { } } -// 추가 테스트 설정 (루트에서 기본 설정됨) -tasks.named('test') { - systemProperty 'spring.profiles.active', 'test' -} - -// JAR 파일명 설정 -jar { - archiveBaseName = 'api-gateway' - enabled = false -} - bootJar { 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' - ] - } -} \ No newline at end of file diff --git a/bill-service/build.gradle b/bill-service/build.gradle index 0f9cc81..0085bfe 100644 --- a/bill-service/build.gradle +++ b/bill-service/build.gradle @@ -1,10 +1,6 @@ // bill-service 모듈 // 루트 build.gradle의 subprojects 블록에서 공통 설정 적용됨 -plugins { - id 'jacoco' -} - dependencies { // Database (bill service specific) runtimeOnly 'org.postgresql:postgresql' @@ -36,62 +32,7 @@ dependencies { 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 { archiveFileName = 'bill-service.jar' enabled = true - archiveClassifier = '' } \ No newline at end of file diff --git a/build.gradle b/build.gradle index f9e6045..9ea5dd8 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,8 @@ plugins { id 'org.springframework.boot' version '3.3.0' apply false id 'io.spring.dependency-management' version '1.1.6' 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' @@ -18,7 +20,7 @@ allprojects { subprojects { apply plugin: 'java' apply plugin: 'io.freefair.lombok' - + if (it.name == 'common') { apply plugin: 'io.spring.dependency-management' } else { @@ -26,6 +28,13 @@ subprojects { apply plugin: 'io.spring.dependency-management' } + apply plugin: 'org.sonarqube' + apply plugin: 'jacoco' // 서브 프로젝트에 JaCoCo 플러그인 적용 + + jacoco { + toolVersion = "0.8.11" // JaCoCo 최신 버전 사용 + } + java { toolchain { languageVersion = JavaLanguageVersion.of(21) @@ -53,6 +62,36 @@ subprojects { openaiVersion = '0.18.2' 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) diff --git a/kos-mock/build.gradle b/kos-mock/build.gradle index 2abfce6..501a4de 100644 --- a/kos-mock/build.gradle +++ b/kos-mock/build.gradle @@ -1,12 +1,6 @@ // kos-mock 모듈 // 루트 build.gradle의 subprojects 블록에서 공통 설정 적용됨 -configurations { - compileOnly { - extendsFrom annotationProcessor - } -} - dependencies { // Spring Boot implementation 'org.springframework.boot:spring-boot-starter-web' @@ -41,17 +35,6 @@ dependencies { 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 { archiveFileName = 'kos-mock.jar' } \ No newline at end of file diff --git a/kos-mock/data/kos_mock.mv.db b/kos-mock/data/kos_mock.mv.db index 3339629..e39e2dd 100644 Binary files a/kos-mock/data/kos_mock.mv.db and b/kos-mock/data/kos_mock.mv.db differ diff --git a/kos-mock/src/main/resources/application.yml b/kos-mock/src/main/resources/application.yml index a7124da..284b3e5 100644 --- a/kos-mock/src/main/resources/application.yml +++ b/kos-mock/src/main/resources/application.yml @@ -82,5 +82,3 @@ springdoc: operations-sorter: alpha show-actuator: true 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" diff --git a/product-service/build.gradle b/product-service/build.gradle index 4759775..0a00d33 100644 --- a/product-service/build.gradle +++ b/product-service/build.gradle @@ -30,160 +30,8 @@ dependencies { 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 { - enabled = false - archiveClassifier = '' -} - bootJar { enabled = true - archiveClassifier = '' - 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')}" - ) - } + archiveFileName = "product-service.jar" } - -// 개발 환경 설정 -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' - ] -} \ No newline at end of file diff --git a/user-service/build.gradle b/user-service/build.gradle index 09302d4..0a9cf46 100644 --- a/user-service/build.gradle +++ b/user-service/build.gradle @@ -26,16 +26,6 @@ dependencies { // 추가 테스트 설정 (루트에서 기본 설정됨) // JAR 파일명 설정 -jar { - archiveBaseName = 'user-service' - enabled = false -} - bootJar { archiveFileName = 'user-service.jar' } - -// Spring Boot 실행 설정 -springBoot { - mainClass = 'com.phonebill.user.UserServiceApplication' -} \ No newline at end of file