-
[Gradle] build.gradle 분석SpringBoot/Gradle 2021. 9. 28. 08:57
buildscript { ext { (1) springBootVersion = '2.2.9.RELEASE' } repositories { (2) mavenCentral() } dependencies { (3) classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } }
(1) ext
- build.gradle에서 사용하기 위한 전역변수를 선언하고 정의하는 부분
- sptingBootVersion이라는 전역변수를 선언하고 해당 전역변수의 값을 '2.2.9.RELEASE'로 정의
- 이후 (3)에서 전역변수 springBootVersion값을 사용
(2) repositories
- 각종 의존성(라이브러리)들을 어떤 원격 저장소로부터 받아올지 정의
- 보통 mavenCentral()과 jcenter()를 사용
- 위 두 저장소는 모두 Android Studio의 gradle플러그인 용 저장소
- mavenCentral()의 라이브러리 업로드 과정이 비교적 어려워 요즘은 jcenter()를 주로 사용
(3) dependencies
- 2.2.9.RELEASE(springBootVersion) 버전의 스프링부트 그레이들 플러그인을 의존성으로 받음
(#) buildscript내의 내용들은 build.gradle 자체의 빌드를 위해 설정하는 요소들인것 같음
apply plugin: 'java' apply plugin: 'war' (1) apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management'
(1) war plugin
- war파일로 배포하기 위해 플러그인 추가
(나머지)
- 자바와 스프링부트를 이용한 프로젝트를 진행하기 위해 추가해야 하는 필수 플러그인
group = 'maum.qa' version = '0.0.0' sourceCompatibility = '1.8'
(1) group
- 프로젝트 생성시의 groupID
(2) version
- 애플리케이션의 버전
- 보통 버전 뒤에 SNAPSHOT을 붙이면 아직 개발 중인 애플리케이션을 의미
(3) sourceCompatibility
- Java소스를 컴파일 하기 위한 Java 버전
(#) sourceCompatibility를 제외한 나머지는 필수 요소가 아닌듯함
Dependency configuration
implementation 'org.springframework.boot:spring-boot-starter-aop' compileOnly 'org.springframework.boot:spring-boot-starter-aop' runtimeOnly 'org.springframework.boot:spring-boot-starter-aop'
(1) implementation: 구현할 때만 사용
(2) compileOnly: 컴파일 시에만 사용되고, 런타임 때는 사용되지 않음
(3) runtimeOnly: 런타임 때만 사용
'SpringBoot > Gradle' 카테고리의 다른 글
[Gradle] Gradle Build System 분석 (0) 2021.09.28