1. Gradle Wrapper가 뭘까?
Spring Boot initializer를 이용해서 project를 import할 때,
이 작업을 해야 하는 이유는 우리가 윈도우에 그래들을 설치하지 않았기 때문이다. 대신 Spring Initializr에서 프로젝트를 다운받을 때 gradlew라는 프로그램을 다운 받았는데 gradlew가 바로 그래들 래퍼 Gradle Wrapper다. 따로 그래들을 설치할 필요 없이 또는 이미 설치된 그래들 버전과의 호환 문제 방지를 위해 프로젝트 내의 그래들 래퍼를 사용한다.
위와 같은 이유로 Gradle distribution에서 Gradle wrapper를 선택하라고 했다.
https://docs.gradle.org/current/userguide/gradle_wrapper.html
Gradle Wrapper Reference
It is always recommended to execute a build with the Wrapper to ensure a reliable, controlled, and standardized execution of the build. Using the Wrapper looks like running the build with a Gradle installation. Depending on the operating system you either
docs.gradle.org
Gradle Wrapper Reference 공식 문서에서 아래와 같은 설명이 나온다.
The recommended way to execute any Gradle build is with the help of the Gradle Wrapper (referred to as "Wrapper"). The Wrapper is a script (called gradlew or gradlew.bat) that invokes a declared version of Gradle, downloading it beforehand if necessary. Instead of running gradle build using the installed Gradle, you use the Gradle Wrapper by calling ./gradlew build.
Gradle Wrapper는 프로젝트에 지정된 Gradle 버전으로 빌드를 실행할 수 있게 해주는 스크립트 도구이다. 이름에서 알 수 있듯이, Gradle 자체를 감싸는(wrapper) 역할을 하며, gradlew, gradlew.bat, 그리고 gradle/wrapper/gradle-wrapper.properties 등의 파일로 구성된다.
라고 하는데 Gradle Wrapper가 필요한 이유는, 개발자마다 Gradle을 다르게 설치해 놓았을 가능성이 있다. 이때, Wrapper를 사용하면 프로젝트마다 정해진 버전의 Gradle을 자동으로 다운로드해서 실행한다.
또 Gradle을 따로 설치하지 않아도 되는데 Wrapper가 자동으로 Gradle 바이너리를 다운로드해서 사용한다.
./gradlew build
위 명령어 한 번만 실행하면 된다.
2. 📁 Gradle Wrapper 구성 파일
- gradlew : 유닉스(Linux/macOS)용 실행 스크립트
- gradlew.bat : Windows용 실행 스크립트
- gradle/wrapper/gradle-wrapper.jar : Wrapper 실행 로직
- gradle/wrapper/gradle-wrapper.properties : 사용할 Gradle 버전과 다운로드 URL 설정
Gradle Wrapper 구성 파일이 위와 같은데
Spring Boot initializer를 압축해제 하고 나서 파일을 보면 gradlew가 있다. 따라서 프로젝트 폴더에 gradle wrapper의 구성파일인 gradlew를 포함하면 개발자들이 gradle을 따로 다운로드 받지 않고 동일한 gradle 버전을 사용할 수 있게 된다.
'React.js, 스프링 부트, AWS로 배우는 웹 개발 101' 카테고리의 다른 글
[TIL] 25/05/12, @PathVariable 사용시, java.lang.IllegalArgumentException 예외 발생 (0) | 2025.05.13 |
---|---|
[TIL] 25/02/16, 서비스 개발 및 실습(2) (0) | 2025.02.18 |
[Error] JPQL 문법 오류 (0) | 2025.02.17 |
[TIL] 25/02/16, 서비스 개발 및 실습(1) (0) | 2025.02.17 |
[TIL] 25/01/29, 퍼시스턴스 레이어 : 스프링 데이터 JPA (0) | 2025.01.29 |