build.gradle
plugins {
id 'java-library' // 자바
id 'org.springframework.boot' version '3.4.11' apply false // spring boot
id 'io.spring.dependency-management' version '1.1.7' apply false // spring boot 버전에 맞는 의존성의 버전을 자동으로 설정
}
allprojects { // 모든 프로젝트(전체 모듈)에 적용되는 설정 정보
group = 'com.mcargo' // 전체 프로젝트의 공통 패키지 명 (관례 : 도메인을 뒤집어 작성, www.naver.com -> com.naver)
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
repositories {
mavenCentral() // 의존성을 가져오는 저장소 위치
}
ext {
set('springCloudVersion', "2024.0.2")
}
tasks.withType(Test).configureEach {
useJUnitPlatform() // 테스트 도구
}
// java JAR 구분
// excutable vs plain
// 실제 실행 가능 참조만 가능
// common(참조용 모듈, 실제 API 수행 X, 실행할 필요 X) : Plain JAR
tasks.withType(Jar).configureEach {
enabled = false
}
// 실행 해야 하는 micro-service : Excutable JAR (BootJar)
tasks.withType(BootJar).configureEach {
enabled = true
}
}
// 이곳에 저장되는 정보는 모든 프로젝트에 영향을 주기 때문에, 최소화하여 필수 기능들만 추가하도록 함
subprojects { // 각 프로젝트에 공통 설정되어있는 플러그인, dependency 구성
apply plugin: 'java-library'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.springframework.boot'
plugins.withId('org.springframework.boot') {
tasks.withType(BootJar).configureEach {
enabled = true
}
}
dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
tasks.named('test') {
useJUnitPlatform()
}
}
setting.gradle : 이 프로젝트가 멀티 모듈임을 셋팅
rootProject.name = 'mcargo'
include 'user-service'
, 'order-service'
, 'gateway'
, 'delivery-service'
, 'hub-service'
, 'eureka-server'
, 'common'
, 'auth-service'
build.gradle(:delivery-service)dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
implementation project(':common') // 공통 모듈
runtimeOnly 'org.postgresql:postgresql' // postgres
}