본문 바로가기

Backend Develop/Build Tools

[Gradle] Gradle의 의존성 관리 옵션(implementation, compileOnly 등)

Dependecy Configuration

크게 아래와 같이 3가지의 Option으로 정의할 수 있다. 먼저 Classpath를 알아야 한다. Classpath는 참조하는 Library나 File들의 위치이다. 크게 CompileClasspath와 RuntimeClasspath로 나눌 수 있다. CompileClasspath는 Compile Time에 참조하는 Classpath를 말하고 RuntimeClasspath는 Runtime에 참조하는 Classpath를 말한다.

 

  1. implementation
    해당 옵션으로 선언된 Dependency Library들은 CompileClasspath와 RuntimeClasspath 모두 들어가게 된다.
  2. compileOnly
    해당 옵션이 적용되면 CompileClasspath에만 들어가기 때문에 Runtime 시에는 참조되지 않는다.
    대표적으로 Lombok 라이브러리가 이 경우에 해당된다.
  3. runtimeOnly
    해당 옵션이 적용되면 RuntimeClasspath에만 들어가서 Compile 시에는 적용안되고 Runtime 시점에만 참조가 된다.대표적으로 DB나 Log 관련 Library가 이 경우에 해당된다.

 

참고사이트