Gradle Java Project

Codelist·2023년 4월 18일
0

gradle

목록 보기
3/7

plugins

  • build에 사용할 plugin 설정
  • plugin 추가시, 추가한 plugin에 정의된 task 사용 가능함
plugins {
    id 'java'
    id 'application'
}

dependencies

  • project에서 사용하는 library를 설정하는 영역
  • scope 'group-id:artifact-name:version' 형태로 명시함
implementation 'com.google.guava:guava:31.1-jre'

scope (configurations)

  • implementation - compile와 runtime 시점 둘 다 사용
    • maven : compile
  • compileOnly - compile에만 사용
    • maven : provided
  • runtimeOnly - runtime에만 사용
    • maven : runtime
  • api (구 compile)
    • multi project구성시, 하위 프로젝트까지 dependency가 적용되게 함
    • 하위에 동일한 library로 dependency설정시 중복으로 오류 발생
  • testImplementation - 테스트 수행시, compile, runtime 둘 다 사용
  • testCompileOnly - 테스트 수행시, compile에만 사용
  • testRuntimeOnly - 테스트 수행시, runtime에만 사용

repositories

  • dependencies에서 설정한 library들을 가져올 repository(경로)를 명시함
  • 대표적으로 mavenCentral()을 사용함
  • 별도로 구성 repository경로 사용도 가능함
repositories {
    mavenCentral()
    mavenLocal() // 로컬 maven repository
}
  • library를 로컬에 다운받는 저장하는 경로
    /Users/userName/.gradle/caches/jars-9
profile
Backend Developer

0개의 댓글