๐ง ์๋ก
Gradle ํ๋ก์ ํธ๋ฅผ ๋น๋ํ๊ณ ์คํํ๊ธฐ ์ํด์๋, ๋ก์ปฌ ์ปดํจํฐ์ ํด๋น ํ๋ก์ ํธ์ ๋์ผํ ๋ฒ์ ์ด ๋์ผํด์ผ ํฉ๋๋ค.
๋ง์ฝ ์ด๋ค์ด ์ผ์นํ์ง ์๋๋ค๋ฉด, ๋น์ฐํ๊ฒ๋ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
๋ฐ๋ผ์, ํญ์ ์ฌ์ฉํ๋ ค๋ ํ๋ก๊ทธ๋จ์ Gradle ๋ฒ์ ๊ณผ ๋์ผํ๊ฒ Gradle์ ์ค์นํด์ฃผ์ด์ผ ํ๋๋ฐ ์ด๋ ๊ต์ฅํ ๊ท์ฐฎ๊ณ ๋นํจ์จ์ ์ธ ๋ฐฉ๋ฒ์ ๋๋ค.
Gradle Wrapper(์ดํ Wrapper)๋ ์ด๋ฌํ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํด์ค๋๋ค.
๐ง Gradle Wrapper
์ง์ ๋ ๋ฒ์ ์ Gradle์ ์คํํ๋ ์คํฌ๋ฆฝํธ๋ก, ํ์ํ ๊ฒฝ์ฐ Gradle ๋ฐฐํฌํ(distribution)์ ๋ฐฐํฌ ์๋ฒ์์ ๋ค์ด๋ก๋ํฉ๋๋ค.
Wrapper๋ฅผ ์ฌ์ฉํ๋ฉด Gradle์ ์ค์นํ์ง ์๊ณ ๋ ์ง์ ๋ Gradle ๋ฒ์ ์ผ๋ก ๋น๋๋ฅผ ์งํํ ์ ์์ต๋๋ค.
Wrapper๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด์๋ Wrapper ํ์ผ๋ค์ด ํ์ํ๋ฐ, ์ด๋ฅผ ์์ฑํ๊ธฐ ์ํด์๋ Gradle์ด ์ค์น๋์ด ์์ด์ผ ํฉ๋๋ค.
(Wrapper๋ ํ๋ฒ๋ง ์์ฑํ๋ฉด ์ดํ ๊ณ์ ์ฌ์ฉํ ์ ์์ผ๋ฏ๋ก, ์ด๋ฏธ Wrapper ํ์ผ์ด ์์ฑ๋ ๊ฒฝ์ฐ Gradle์ ์ค์น ์์ด ์ฌ์ฉ ๊ฐ๋ฅํฉ๋๋ค.)
Gradle์ wrapper๋ผ๊ณ ๋ถ๋ฆฌ๋ ๊ธฐ๋ณธ task๋ฅผ ์ ๊ณตํฉ๋๋ค.
wrapper task๊ฐ ์คํ๋๋ฉด ๋ค์๊ณผ ๊ฐ์ Wrapper ํ์ผ๋ค์ด ์์ฑ๋ฉ๋๋ค.
.
โโโ gradle
โ โโโ wrapper
โ โโโ gradle-wrapper.jar
โ โโโ gradle-wrapper.properties
โโโ gradlew
โโโ gradlew.bat
๐ gradle-wrapper.jar
Gradle ๋ฐฐํฌํ์ ๋ค์ด๋ก๋ํ๋ ์ฝ๋๊ฐ ํฌํจ๋ JAR ํ์ผ์ ๋๋ค.
๐ gradle-wrapper.properties
ํ์ฌ ํ๋ก์ ํธ์ ํธํ๋๋ Gradle ๋ฐฐํฌํ์ ๋ฒ์ ์ ํฌํจํ์ฌ Gradle Wrapper์ ๋ฐํ์ ์์ฑ์ด ํฌํจ๋ฉ๋๋ค.
๐ gradlew, gradle.bat
Wrapper๋ฅผ ํตํด ๋น๋๋ฅผ ์คํํ๋ ์คํฌ๋ฆฝํธ์ ๋๋ค.
gradlew๋ ๋งฅ๊ณผ ๋ฆฌ๋ ์ค์ฉ ์คํฌ๋ฆฝํธ์ด๋ฉฐ,
gradle.bat์ ์๋์ฐ์ฉ ์คํฌ๋ฆฝํธ์ ๋๋ค.
๐ Wrapper ๋ฒ์ ๋ณ๊ฒฝํ๊ธฐ
๊ธฐ๋ณธ์ ์ผ๋ก wrapper ์์ (task)์ ์ค์น๋ Gradle ๋ฒ์ ๊ณผ ๋์ผํ ๋ฒ์ ์ Wrapper ํ์ผ์ ์์ฑํฉ๋๋ค.
๋ง์ฝ ๋ฒ์ ์ ๋ฐ๊พธ๊ณ ์ถ๋ค๋ฉด, ๋ค์๊ณผ ๊ฐ์ด ์ต์ ์ ํตํด ์ค์ ํ ์ ์์ต๋๋ค.
gradle wrapper --gradle-version 8.1
๐ง Wrapper๋ฅผ ํตํด Gradle ์ฌ์ฉํ๊ธฐ
Gradle ๋น๋๋ ํญ์ Wrapper๋ฅผ ํตํด ์คํํ๋ ๊ฒ์ด ๊ถ์ฅ๋ฉ๋๋ค.
Wrapper๋ gradlew๋ฅผ ํตํด ๋ค์๊ณผ ๊ฐ์ด ์ฌ์ฉํ ์ ์์ต๋๋ค.
./gradlew [ํ์คํธ ์ด๋ฆ]
์๋ gradle [ํ์คํฌ ์ด๋ฆ]๊ณผ ๋์ผํ ์ญํ ์ ํ๋๋ฐ, ์ปดํจํฐ์ ์ค์น๋ gradle์ด ์๋ wapper๋ฅผ ์ฌ์ฉํ๋ค๋ ๊ฒ์ด ์ฐจ์ด์ ์ ๋๋ค.
gradle.bat์ ๋ค์๊ณผ ๊ฐ์ด ์ฌ์ฉํ ์ ์์ต๋๋ค.
gradlew.bat [ํ์คํธ ์ด๋ฆ]
์๋์ฐ์์๋ ./ ์ ์ฌ์ฉํ์ง ์์๋ ๋ฉ๋๋ค.
๐ง settings.gradle
๋น๋์ ์ฐธ์ฌํ๋ project๋ค์ ๊ณ์ธต๊ตฌ์กฐ๋ฅผ ์ธ์คํด์คํํ๊ณ ๊ตฌ์ฑํ๋๋ฐ ํ์ํ ์ค์ ์ ์์ฑํฉ๋๋ค.
settings.gradle์ ๋ชฉ์ ์ค ํ๋๋ ๋น๋์ ํฌํจ๋ ํ๋ก์ ํธ๋ค์ ์ค์ ํ๋ ๊ฒ์ ๋๋ค.
ํ๋ก์ ํธ๋ค์ include ๋ฉ์๋๋ฅผ ํตํด ์ถ๊ฐ๋ ์ ์์ต๋๋ค.
Gradle์ ๋น๋๊ฐ ์คํ๋ ๋๋ง๋ค settings.gradle ํ์ผ์ ์ฐพ์, ํด๋น ํ์ผ์ ์ฐธ๊ณ ํ์ฌ ๋น๋๋ฅผ ์ด๊ธฐํํฉ๋๋ค.
๋ง์ฝ settings.gradle ํ์ผ์ด ์๋ ๋๋ ํ ๋ฆฌ์์ gradle์ ์คํํ๋ ๊ฒฝ์ฐ ๋ค์ ์์๋ฅผ ๋ฐ๋ฆ ๋๋ค.
- ์ฐ์ ์์ ๋๋ ํ ๋ฆฌ์์ ์ฐพ์ต๋๋ค.
- ์์ ๋๋ ํ ๋ฆฌ์์ ์กด์ฌํจ์ด ํ์ธ๋์๋ค๋ฉด, ํ์ฌ ํ๋ก์ ํธ๊ฐ multi-project ๋น๋์ ์ฐธ์ฌํ๋์ง ํ์ธํฉ๋๋ค. ์ฐธ์ฌํ๋ค๋ฉด Gradle์ multi-project๋ก ๋น๋๋ฉ๋๋ค.
- ๋ง์ฝ ์ฐพ์ง ๋ชปํ๋ค๋ฉด Gradle์ ๋จ์ผ ํ๋ก์ ํธ๋ก ๋น๋๋ฉ๋๋ค.
๐ multi-project ์ถ๊ฐํ๋ ์์
๊ตฌ์กฐ๋ ๋ค์๊ณผ ๊ฐ๋ค๊ณ ํ๋ฉด
basic-multiproject
โโโ app
โ ...
โ โโโ build.gradle
โโโ lib
โ ...
โ โโโ build.gradle
โโโ settings.gradle
๋ค์๊ณผ ๊ฐ์ด settings.gradle์ ์์ฑํฉ๋๋ค.
rootProject.name = 'basic-multiproject'
include 'app'
include 'lib'
๐ Reference
https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:using_wrapper
The Gradle Wrapper
It is recommended to always execute a build with the Wrapper to ensure a reliable, controlled and standardized execution of the build. Using the Wrapper looks almost exactly like running the build with a Gradle installation. Depending on the operating syst
docs.gradle.org
Settings - Gradle DSL Version 8.1
Declares the configuration required to instantiate and configure the hierarchy of Project instances which are to participate in a build. There is a one-to-one correspondence between a Settings instance and a settings.gradle settings file. Before Gradle ass
docs.gradle.org
https://docs.gradle.org/current/userguide/build_lifecycle.html#sec:initialization
Build Lifecycle
Gradle is an example of dependency based programming: you define tasks and dependencies between tasks. Gradle guarantees that these tasks execute in the order of their dependencies. Your build scripts and plugins configure this dependency graph. This page
docs.gradle.org
https://docs.gradle.org/current/userguide/organizing_gradle_projects.html#sec:settings_file
Organizing Gradle Projects
It’s very common that a project defines and executes different types of tests e.g. unit tests, integration tests, functional tests or smoke tests. Optimally, the test source code for each test type should be stored in dedicated source directories. Separa
docs.gradle.org
https://docs.gradle.org/current/userguide/multi_project_builds.html#sec:adding_subprojects
Structuring and Building a Software Component with Gradle
If you are building a software of a certain size with Gradle, you have two basic structuring mechanisms. First, this chapter describes how to structure your software project using a Gradle multi-project. In this documentation, we consider this to be a sing
docs.gradle.org
'๐ Gradle' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Gradle] api์ implementation์ ์ฐจ์ด (feat. java-libraly ํ๋ฌ๊ทธ์ธ) (0) | 2023.04.16 |
---|---|
[Gradle] ์๋ฐ ํ๋ฌ๊ทธ์ธ (0) | 2023.04.15 |
[Gradle] Dependency Configuration์ด๋? (0) | 2023.04.15 |
[Gradle] ์์กด์ฑ ๊ด๋ฆฌ(Dependency management)๋? (0) | 2023.04.15 |
[Gradle] Gradle์ ๊ตฌ์ฑ์์(Project, Task, Plugin)์ ์์ํด๋ณด๊ธฐ (0) | 2023.04.14 |