dependencies 로컬 Gradle 프로젝트로 바꾸는 방법

로컬 Gradle 프로젝트로 바꾸는 방법은 크게 두 가지(멀티모듈 vs. 컴포지트 빌드)가 있습니다.
이미 어떤 구조로 되어 있느냐에 따라 선택하시면 됩니다.

1. 같은 리포 안 멀티모듈인 경우

예: 현재 리포 안에 automail-api도 Gradle 프로젝트로 같이 있는 경우.

  1. 루트 settings.gradle에 모듈 포함

    groovy
    // settings.gradle
    rootProject.name = 'your-root'

    include ':automail-api'
    // 기존 app 모듈 등도 같이
    include ':app'

  2. 사용하는 프로젝트 build.gradle에서 의존성 변경

    groovy
    dependencies {
    // 기존 외부 의존성
    // implementation 'com.andwise:automail-api:1.0'

    // 로컬 모듈 의존성
    implementation project(':automail-api')
    }

이렇게 하면 automail-api 모듈을 같이 빌드하고, 변경 사항이 바로 반영됩니다.

2. 별도 리포/폴더인 경우 (Composite Build)

dependencies 로컬 Gradle 프로젝트로 바꾸는 방법

automail-api가 다른 디렉터리/리포에 있고, 그래도 로컬 소스를 직접 쓰고 싶을 때는 includeBuild를 사용합니다.

  1. 메인 프로젝트의 settings.gradle에 로컬 프로젝트 추가

    groovy
    // settings.gradle
    rootProject.name = 'your-app'

    includeBuild '../automail-api' // automail-api 로컬 경로

  2. build.gradle의 의존성은 그대로 둠

    groovy
    dependencies {
    implementation 'com.andwise:automail-api:1.0'
    }

includeBuild를 사용하면 동일한 GAV(com.andwise:automail-api:1.0)를 가진 로컬 Gradle 프로젝트를 자동으로 우선 사용하므로, 의존성 문자열을 바꾸지 않아도 로컬 프로젝트가 사용됩니다.