MSA 프로젝트 환경세팅을 하던 중 Multi Repo와 Mono Repo 중 어떤 방식을 채택할 지 고민을 하다가 Multi Module을 활용한 Mono Repo 구성을 해보는게 어떠냐는 조언을 듣고 프로젝트에 한번 적용해보기로 했음
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.3'
id 'io.spring.dependency-management' version '1.1.6'
}
repositories {
mavenCentral()
}
subprojects {
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.sparta3tm'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
ext {
set('springCloudVersion', "2023.0.3")
}
dependencies {
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
}
test {
useJUnitPlatform()
}
}
dependencies {
// lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// DB
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
// zipkin
implementation 'io.micrometer:micrometer-tracing-bridge-brave'
implementation 'io.zipkin.reporter2:zipkin-reporter-brave'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
// prometheus
runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter'
}
rootProject.name = '3TM'
include 'common'
생성 예시는 생략
settings.gradle 삭제 ( rootProject가 아님 )
build.gradle 작성 (공통 모듈에 들어가는 부분 제외하고 설정)
dependencies {
// Swagger
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.2.0'
// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// DB
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'org.postgresql:postgresql'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
// Eureka
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
// OpenFeign
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
// Zipkin
implementation 'io.github.openfeign:feign-micrometer'
implementation 'io.micrometer:micrometer-tracing-bridge-brave'
implementation 'io.zipkin.reporter2:zipkin-reporter-brave'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
rootProject.name = '3TM'
include 'common'
include 'company-server'
// 기존 build.gradle 아래 부분에 추가
project(':company-server'){
dependencies {
implementation project(':common')
}
}
루트 subprojects 에서 plugins 사용하고 서브프로젝트의 build.gradle 에서 plugins 사용하면 build.gradle 의 plugins 이 우선돼 subprojects 의 구문이 전부 무시됩니다 ㅠ