Repository

Repository

resolve dependency

repository 선언

gradle은 resolve 시 명시한 순서대로 의존성을 repository에서 찾음

repositories {
    mavenCentral()
    google()
    maven {
        url = uri("https://custom-repo.com")
    }
}

Dependency Metadata

Dependency : build script에 명시한 project build 시 필요한 의존성(artifact)들

repository format

.pom file that is describes project

maven repository에 publish되는 artifact는 .pom 파일에 프로젝트에 대한 정보를 설명해놓음

gradle은 해당 정보를 통해 의존성을 가져옴(dependency coordinate)

또한 해당 파일에 transitive 의존성이 명시되어 있는데 gradle은 전체 의존성을 파악하여 모두 가져옴

transitive dependency

특정 의존성 모듈 제외 명시 방법

transitive 의존성을 제외하는 경우 해당 의존성을 필요로 하는 의존성마다 exclude를 명시 해줘야 됨

// transitive dependency 제외
implementation("group:artifact:version") {
    exclude(group = "group", module = "module")
}

Classpath, Production classpath

프로젝트를 빌드하는 동안 여러 단계를 거침

컴파일 -> 테스트 -> 실행

자바의 classpath는 애플리케이션을 컴파일하거나 실행할 때 jvm에게 전달되는 파일 리스트임

Compile phase requires compile classpath and run phase requires runtime classpath

Gradle gives us fine-grained control of classpath using dependency configurations

compile classpath

runtime classpath

production classpath

Production classpath dependency configuration

implementation("group:artifact:version")

implementation(group = "group", name = "artifact", version = "version")

dependency configuration

Note

Each resolvable dependency configuration has combination of unresolvable dependency configurations

production classpath dependency configuration

 annotationProcessor("org.projectlombok:lombok:1.18.32")

dependency configuration that java plugin uses

Test classpath dependency configuration

Similar to production classpath, tests have their own testCompileClassPath, testRuntimeClasspath resolvable dependency configurations

They also have their own testCompileOnly, testImplementation and testRuntimeOnly unresolvable dependency configurations which you can declare against

test dependency configurations extend other

compileTestJava, test task of java plugin