sopt-makers / sopt-auth-backend

3 stars 0 forks source link

[SETTING/#3] 프로젝트를 멀티 모듈로 분리합니다. #4

Closed hyunw9 closed 3 weeks ago

hyunw9 commented 3 weeks ago

Related Issue 🚀

Work Description ✏️

1. 단일 모듈 -> core-api, domain, infra, support 모듈로 분리하였습니다.

기존에 작성된 build.gradle.kts, settings.gradle.kts를 참고하여 구성하였습니다.

settings.gradle

https://github.com/sopt-makers/sopt-auth-backend/blob/5056c894e43a17723572851c771fbc651c243924/settings.gradle.kts#L6-L16

spring boot, dependency Management, spotless 3개의 플러그인을 사용하고 있었습니다. 각 모듈별로 공통된 설정을 적용하기 위해, settings.gradle 로 분리하였습니다.

아래는 include를 사용하여 하위모듈로 포함시켰습니다.

build.gradle.kts

https://github.com/sopt-makers/sopt-auth-backend/blob/5056c894e43a17723572851c771fbc651c243924/build.gradle.kts#L25-L49

핵심 부분입니다. 위에서 분리한 plugins를 subproject 내부에 plugin으로 적용하였습니다.

다만, springboot같은 경우는 공통으로 포함시키지 않았는데요, Domain모듈은 스프링부트 종속성이 없기 때문에 추가할 경우 오류가 발생했습니다.

-> 각 모듈간 최소한의 종속성만 관리하면 되므로 조금더 직관적이지 않아졌나.. 생각이 됩니다.

2. 각 모듈 root 에 interface를 추가하였습니다.

각 모듈별로 구성할때는 propertyScan을 사용할 때가 많은데요, 개인적으로 클래스보다는 아무 역할이 없는 인터페이스가 보기 편한 것 같아 형식적으로 추가하였습니다.

3. 모듈간 컨텍스트 로드 확인

domain, infra, support 모듈의 spring 컨테이너가 잘 구동되는지 테스트 진행하였습니다. core-api 모듈은 의존하는 모듈들의 컨텍스트를 모두 로드하여 테스트를 진행했습니다.

PR Point 📸

사실 멀티모듈이 정형화된 구조도 없고, 정답도 없다고 생각합니다.

의문점이 드시는 부분은 언제든지 리뷰 부탁드립니다 !

height[bot] commented 3 weeks ago

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

yummygyudon commented 3 weeks ago

우선 꽤 번거러운 작업이었을텐데 고생 많으셨습니다! 마지막 말씀에 많은 공감을 합니다!

확인하시면 바로 머지하셔도 될 것 같습니다!!