새롭게 시작하는 개발 이야기/프로젝트
멀티 모듈 subProject 설정하기.
Resian
2022. 7. 29. 18:17
개요
최상위 프로젝트 build.gralde을 통하여 하위 프로젝트들을 관리하려 함.
내용
아래 코드처럼 common api 적용하였으나 하위 모듈에서 라이브러리를 읽어오지 못함.
rootProject.name = 'mlmall'
include 'app-auth'
buildscript {
ext{
springBootVersion = '2.7.1'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath "io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE"
}
}
subprojects {
group = 'com'
version = '0.0.1-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = '17'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation "org.springframework.boot:spring-boot-starter-data-jpa"
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
runtimeOnly group: 'com.h2database', name: 'h2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
}
project(':app-auth') {
dependencies {
}
}
해결
subprojects에 repositoryes를 추가함.
buildscript {
ext{
springBootVersion = '2.7.1'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath "io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE"
}
}
subprojects {
group = 'com'
version = '0.0.1-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = '17'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
}
project(':app-auth') {
dependencies {
compile project(':app-common')
}
}
project(':app-common') {
dependencies {
}
}
회고
멀티모듈을 이렇게까지 설정해본건 처음인데 생각보다 복잡했다.
이제 모듈과 모듈 사이 관계도 조정해야하는데 잘 안되서 한참 헤맬 듯 하다.