1. Maven
- Java ํ๋ก์ ํธ ๋น๋ ํด
- ๋น๋ ํ๋ก์ธ์ค๋ฅผ ๋จ์ํํ๋ ค๋ ์๋๋ก ์์๋์๋ค.
- ๋ณดํต Java ํ๋ก์ ํธ์์ ์ฌ์ฉํ์ง๋ง Java ํ๋ก์ ํธ ๋ฟ ์๋๋ผ JVM์์ ๋์ํ๋ Kotlin or Scale์์๋ ์ฌ์ฉํ ์ ์๊ณ ์ฌ์ง์ด C#, Ruby์์๋ ์ฌ์ฉ ํ ์ ์๋ค.
You can not only build Java projects with it, but pretty much every project written in a JVM language like Kotlin or Scala, as well as other languages like C# and Ruby.

2. ํน์ง
- ์ข
์์ฑ ๊ด๋ฆฌ: ์ธ๋ถ ๋ผ์ด๋ธ๋ฌ๋ฆฌ(3th-party dependency)๋ฅผ ํ์ฌ ํ๋ก์ ํธ์ ์ฝ๊ฒ ํฌํจ ์ํฌ ์ ์๋ค.
- ์ฐธ๊ณ : ์๋ํํฐ๋ ํ๋ก๊ทธ๋๋ฐ์ ๋์์ฃผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ง๋๋ ์ธ๋ถ ์์ฐ์๋ฅผ ๋ปํ๋ค
- Java - maven โ JS - npm, Ruby - gems, PHP - composer ๊ฐ์ ์ญํ ์ด๋ผ๊ณ ์๊ฐํ๋ฉด ๋๋ค
- ํ๋ก์ ํธ์ ์ฌ์ฉํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ pom.xml์ dependency๋ก ์ ์ ํด ๋์ผ๋ฉด, ๋ฉ์ด๋ธ์ด repository์์ ๊ฒ์ํด์ ์๋์ผ๋ก ์ถ๊ฐํด์ค๋ค. ์ฌ์ง์ด ๊ฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์ฐธ์กฐํ๊ณ ์๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊น์ง ๋ชจ๋ ์ฐพ์์ ์ถ๊ฐํด์ค๋ค. ์ด๊ฒ์ '์์กด์ฑ ์ ์ด' ๋ผ๊ณ ํ๋ค.
- ์ปดํ์ผ: ์ด๋ก ์ ์ผ๋ก๋ ์ง์ javac ์ปดํ์ผ๋ฌ๋ฅผ ์ด์ฉํด ํฐ ๊ท๋ชจ์ ์๋ฐ ํ๋ก์ ํธ๋ฅผ ์ปดํ์ผ ํ ์ ์์ง๋ง, ์ฌ์ค์ ํ์ค์ ์ผ๋ก ํ ์ด ํ๋ก์ ํธ ์ผ ๋๋ ๊ฐ๋ฅํ ์์ค์ด๋ค. Mavan์ ์ฌ์ฉํ๋ค๋ฉด mvn clean install ๋ช ๋ น์ด๋ฅผ ์ด์ฉํด ์์ฝ๊ฒ ์ ์ฒด ํ๋ก์ ํธ ์ปดํ์ผ ๋ฐ ํจํค์ง์ด ๊ฐ๋ฅํ๋ค.
- EveryThing Java: Maven์ ์ฝ๋ ํ๋ฆฌํฐ ์ฒดํฌ ๋ฐ ํ ์คํธ ์ผ์ด์ค ์คํ, ์ฌ์ง์ด ์ธ๋ถ ์๋ฒ์ ์ดํ๋ฆฌ์ผ์ด์ ์ ๋ฐฐํฌํ๋ ๊ฒ๋ ๊ฐ๋ฅํ๋ค.
1. Dependency Management: Maven lets you easily include 3rd party dependencies (think libraries/frameworks such as Spring) in your project. An equivalent in other languages would be Javascriptโs npm, Rubyโs gems or PHPโs composer.
2. Compilation through convention: In theory you could compile big Java projects with a ton of classes, by hand with the javac command line compiler (or automate that with a bash script). This does however only work for toy projects. Maven expects a certain directory structure for your Java source code to live in and when you later do a mvn clean install , the whole compilation and packaging work will be done for you.
3. Everything Java: Maven can also run code quality checks, execute test cases and even deploy applications to remote servers, through plugins. Pretty much every possible task you can think of.
3. Goal
A goal is actually just a Java method which does some specific task within your build.
- Maven์์ ํน์ ์์
์ ์ํํ๋ Java Method๋ผ๊ณ ์๊ฐํ๋ฉด ํธํ๋ค.
- ์ค์ Maven Goal์ void๋ฅผ ๋ฆฌํดํ๋
execute method
์ด๋ค.public void execute () {}
- ์ค์ Maven Goal์ void๋ฅผ ๋ฆฌํดํ๋
- ์ข ๋ ์์ธํ ๊ตฌ์กฐ๋ฅผ ์ดํด๋ณด์๋ฉด, ์์ ๊ฐ์ด ~Mojo class์์ ํ๋์ goal(execute method)์ด ์กด์ฌํ๋ ๊ตฌ์กฐ์ด๋ค.
- Mojo: maven plain old java object
์์๋ ๊ธฐ๋ณธ์ ์ผ๋ก Maven๊ณผ ํจ๊ป ๋ฒ๋ค๋ก ์ ๊ณต๋๋ Maven์ ๋ํ์ ์ธ Goal๊ณผ ์ด๋ฅผ ํฌํจํ๊ณ ์๋ ํ๋ฌ๊ทธ์ธ์ด๋ค. ๋ฌผ๋ก ์์ ๋์ ์๋ Maven์์ ์ ๊ณตํ๋ ํ๋ฌ๊ทธ์ธ ์ธ์ 3rd party ํ๋ฌ๊ทธ์ธ๋ ์ฌ์ฉํ ์ ์๋ค.
- Goal ์คํ์ ๋ค์๊ณผ ๊ฐ์ด ๊ฐ๋ฅํ๋ค.
goal ์คํ ๋ฐฉ๋ฒ : mvn <plugin name>:<goal name>
4. Plugin
- ํ๋ ์ด์์ goal์ ์งํฉ์ฒด.
- ๋น์ ํ์๋ฉด, goal์ ๋ฉ์๋์ด๊ณ Plugin์ goal์ ๋ฉ์๋๋ก ๊ฐ์ง๋ ํด๋์ค๋ผ๊ณ ํ ์ ์๋ค.
// failsafe plugin์์ ์๋ goal ์ค๋ช
๋ณด๊ธฐ
mvn <PLUGIN>:help
mvn failsafe:help
// ๊ฒฐ๊ณผ
This plugin has 3 goals:
failsafe:help
Display help information on maven-failsafe-plugin.
Call mvn failsafe:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
failsafe:integration-test
Run integration tests using Surefire.
failsafe:verify
Verify integration tests ran using Surefire.
5. Phase
Going one level higher, Maven offers a neat way to group multiple goals from multiple plugins. This group of goals is called a phase
- 0๊ฐ ~ N๊ฐ์ Goal๋ค์ ํฌํจํ๋ ์ผ๋ จ์ ๊ทธ๋ฃน
- ์๋ฅผ ๋ค์ด
jar
๋ผ๋Goal
์package Phase
์ ์ผ๋ถ์ด๋ค = jar goal is bound to the package phase
Maybe youโre wondering whatโs the point of having this additional grouping of goals in phases?
Well the answer is that the Maven team wanted to make the system as configurable as possible.
But before I explain that fully, we need to go all the way up to the highest level concept which is the build lifecycle.
๊ทธ๋ฆฌ๊ณ ๋ฐ์๋ ๋ํ์ ์ธ Phase์ ๋ํ ์ค๋ช ์ด๋ค.
validate: check if all information necessary for the build is available
compile: compile the source code
test-compile: compile the test source code
test: run unit tests
package: package compiled source code into the distributable format (jar, war, โฆ)
integration-test: process and deploy the package if needed to run integration tests
install: install the package to a local repository
deploy: copy the package to the remote repository
mvn <phase>
๋ช ๋ น์ ์คํํ๋ ๊ฒ์ phase์ ์ง์ ๋ plugin์ ํน์ goal์ ์คํํ๋ ๊ฒ์ด๋ค.- goal์ด ์๋ phase๋ ์๋ค.
- validate, initialize, verify .. ๋ฑ์ด๋ค.
- ์ด๋ค์ ๋ ๋ฆฝ์ ์ผ๋ก ์คํ๋์ง ์๊ณ , lifecycle์ ํตํด์๋ง ์คํ๋๋ค.
- ๋ค์ ๋ช ๋ น์ ์ฌ์ฉํ์ฌ ํน์ Phase์ ๋ฐ์ธ๋ฉ๋ ๋ชจ๋ Goals์ ํด๋น ํ๋ฌ๊ทธ์ธ์ ๋์ดํ ์ ์๋ค.
mvn help:describe -Dcmd=PHASENAME
mvn help:describe -Dcmd=compile
// ๊ฒฐ๊ณผ
compile' is a phase corresponding to this plugin:
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
6. Lifecycle
A build lifecycle is simply an ordered sequence of phases. The idea is that the lifecycle contains everything required for a full build.
- ๋ผ์ดํ์ฌ์ดํด์ ๋จ์ํ Phase์ ์์๊ฐ ์ง์ ๋ ์ํ์ค์ด๋ค = Maven์ด ๋ฏธ๋ฆฌ ์ ์ ํ๊ณ ์๋ ๋น๋ ์์
- ex)
Default(Build) Maven ๋ผ์ดํ์ฌ์ดํด
์ 23๋จ๊ณ๋ก ๊ตฌ์ฑ๋์ด ์์ผ๋ฉฐ validata ๋ฐ initialization์์ install๋ฐ deploy์ ์ด๋ฅด๋ Phase๋ค์ ํฌํจํ๋ค. ๊ทธ๋ฆฌ๊ณ ๊ฐ Phase๋ ํ๋ฌ๊ทธ์ธ์ ํฌํจ๋ 0 ~ N๊ฐ์ goal๊ณผ ๋งคํ๋๋ค.
- ex)
- ๋ฉ์ด๋ธ์ 3๊ฐ์ ํ์ค ๋ผ์ดํ์ฌ์ดํด์ ์ ๊ณตํ๋ค.
- Clean : ๋น๋ ์ ์์ฑ๋์๋ Output์ ์ง์์ค๋ค โ target ํด๋ ์ญ์
- Default(Build) : ์ผ๋ฐ์ ์ธ ๋น๋ ํ๋ก์ธ์ค๋ฅผ ์ํ ๋ชจ๋ธ์ด๋ค.
- Site : ํ๋ก์ ํธ ๋ฌธ์์ ์ฌ์ดํธ ์์ฑ์ ์ํํ๋ค.
When you pass a phase to the Maven command, first all previous phases in the lifecycle get executed, followed by the phase you specified.
- ๋ง์ฝ Maven Command๋ก phase(ex: mvn install)๋ฅผ ์
๋ ฅํ๋ค๋ฉด, ํด๋น phase์ ์ด์ phase๊ฐ ๋ชจ๋ ์์๋๋ก ์คํ๋ ๋ค์ ์
๋ ฅํ phase๊ฐ ์คํ๋๋ค. (validate ~ intstall๊น์ง ์ ์ฒด ์คํ)
- = ๊ฐ๊ฐ์ phase๋ ์์กด ๊ด๊ณ๋ฅผ ๊ฐ์ง๊ณ ์์ด ์ด๋ค phase๋ฅผ ์คํํ๋ฉด ์ด์ ๋จ๊ณ์ phase๊ฐ ๋ชจ๋ ์ํ ๋๋ค.
- ex: ๋น๋ lifecycle์ ๋ง์ง๋ง ๋จ๊ณ์ธ mvn deploy๋ฅผ ์ํํ๋ฉด default lifecycle์ ๋ชจ๋ phase๊ฐ ์คํ๋๋ค.
๐ ์ ๋ฆฌ
๋ค์ ์ต์์ ๊ฐ๋ ์ธ Lifecycle๋ถํฐ ์ ๋ฆฌํด๋ณด์๋ฉด,
Lifecycle
- Maven์ด ์ ์ํด ๋์ ๋น๋ ์์. ์ด 3๊ฐ๊ฐ ์๋ค.(clean, default, site)
- ์์๊ฐ ์๋ phase๋ค์ ๋ชจ์(?)
phase
- lifecycle์ ๊ฐ ๋จ๊ณ.
- ์๋ฅผ ๋ค์ด clean lifecycle์ 3๊ฐ์ phase๋ก ๊ตฌ์ฑ๋์ด ์๋ค. (pre-clean, clean, post-clean).
- ๊ทธ๋ฆฌ๊ณ ๊ฐ phase๋ ์์กด ๊ด๊ณ๋ฅผ ๊ฐ๊ณ ์์ด ์ด๋ค phase๋ฅผ ์คํํ๋ฉด ์ด์ ๋จ๊ณ์ phase๊ฐ ๋ชจ๋ ์ํ๋๋ค.
goal
- ์ค์ ๋ก ์คํ๋๋ ๋ฉ์๋(ํน์ ์คํ ๋จ์).
- ๊ฐ phase๋ 0๊ฐ, 1๊ฐ, ํน์ ๊ทธ ์ด์์ goal์ ์คํํ๋ค.
plugin
- goal๋ค์ ๊ทธ๋ฃน. goal์ด ๋ฉ์๋๋ผ๋ฉด plugin์ ํด๋์ค์ด๋ค. (ํน์ goal์ ํ๋ฌ๊ทธ์ธ์ ํฌํจ๋์ด ์๋ ๋ช ๋ น์ด์ ๋๋ก ์ดํดํ๋ฉด ๋๋ค).
- ์ฌ์ค Maven ์์ฒด๋ ๊ธฐ๋ณธ์ ์ธ ๊ธฐ๋ฅ๋ง์ ๊ฐ์ง๊ณ ์๊ณ , ๋น๋์ ํ์ํ ๋๋ถ๋ถ์ ๊ธฐ๋ฅ๋ค์ ํ๋ฌ๊ทธ์ธ์ ์คํํด์ ์ ๊ณต ๋๋ ํํ์ด๋ค. = ์ฆ phase๋ฅผ ์คํํ๋ฉด ํด๋น phase์ ์ฐ๊ฒฐ๋ ํ๋ฌ๊ทธ์ธ์ goal์ด ์คํ๋๋ ๊ตฌ์กฐ์ด๋ค.
1. Maven
- Java ํ๋ก์ ํธ ๋น๋ ํด
- ๋น๋ ํ๋ก์ธ์ค๋ฅผ ๋จ์ํํ๋ ค๋ ์๋๋ก ์์๋์๋ค.
- ๋ณดํต Java ํ๋ก์ ํธ์์ ์ฌ์ฉํ์ง๋ง Java ํ๋ก์ ํธ ๋ฟ ์๋๋ผ JVM์์ ๋์ํ๋ Kotlin or Scale์์๋ ์ฌ์ฉํ ์ ์๊ณ ์ฌ์ง์ด C#, Ruby์์๋ ์ฌ์ฉ ํ ์ ์๋ค.
You can not only build Java projects with it, but pretty much every project written in a JVM language like Kotlin or Scala, as well as other languages like C# and Ruby.

2. ํน์ง
- ์ข
์์ฑ ๊ด๋ฆฌ: ์ธ๋ถ ๋ผ์ด๋ธ๋ฌ๋ฆฌ(3th-party dependency)๋ฅผ ํ์ฌ ํ๋ก์ ํธ์ ์ฝ๊ฒ ํฌํจ ์ํฌ ์ ์๋ค.
- ์ฐธ๊ณ : ์๋ํํฐ๋ ํ๋ก๊ทธ๋๋ฐ์ ๋์์ฃผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ง๋๋ ์ธ๋ถ ์์ฐ์๋ฅผ ๋ปํ๋ค
- Java - maven โ JS - npm, Ruby - gems, PHP - composer ๊ฐ์ ์ญํ ์ด๋ผ๊ณ ์๊ฐํ๋ฉด ๋๋ค
- ํ๋ก์ ํธ์ ์ฌ์ฉํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ pom.xml์ dependency๋ก ์ ์ ํด ๋์ผ๋ฉด, ๋ฉ์ด๋ธ์ด repository์์ ๊ฒ์ํด์ ์๋์ผ๋ก ์ถ๊ฐํด์ค๋ค. ์ฌ์ง์ด ๊ฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์ฐธ์กฐํ๊ณ ์๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊น์ง ๋ชจ๋ ์ฐพ์์ ์ถ๊ฐํด์ค๋ค. ์ด๊ฒ์ '์์กด์ฑ ์ ์ด' ๋ผ๊ณ ํ๋ค.
- ์ปดํ์ผ: ์ด๋ก ์ ์ผ๋ก๋ ์ง์ javac ์ปดํ์ผ๋ฌ๋ฅผ ์ด์ฉํด ํฐ ๊ท๋ชจ์ ์๋ฐ ํ๋ก์ ํธ๋ฅผ ์ปดํ์ผ ํ ์ ์์ง๋ง, ์ฌ์ค์ ํ์ค์ ์ผ๋ก ํ ์ด ํ๋ก์ ํธ ์ผ ๋๋ ๊ฐ๋ฅํ ์์ค์ด๋ค. Mavan์ ์ฌ์ฉํ๋ค๋ฉด mvn clean install ๋ช ๋ น์ด๋ฅผ ์ด์ฉํด ์์ฝ๊ฒ ์ ์ฒด ํ๋ก์ ํธ ์ปดํ์ผ ๋ฐ ํจํค์ง์ด ๊ฐ๋ฅํ๋ค.
- EveryThing Java: Maven์ ์ฝ๋ ํ๋ฆฌํฐ ์ฒดํฌ ๋ฐ ํ ์คํธ ์ผ์ด์ค ์คํ, ์ฌ์ง์ด ์ธ๋ถ ์๋ฒ์ ์ดํ๋ฆฌ์ผ์ด์ ์ ๋ฐฐํฌํ๋ ๊ฒ๋ ๊ฐ๋ฅํ๋ค.
1. Dependency Management: Maven lets you easily include 3rd party dependencies (think libraries/frameworks such as Spring) in your project. An equivalent in other languages would be Javascriptโs npm, Rubyโs gems or PHPโs composer.
2. Compilation through convention: In theory you could compile big Java projects with a ton of classes, by hand with the javac command line compiler (or automate that with a bash script). This does however only work for toy projects. Maven expects a certain directory structure for your Java source code to live in and when you later do a mvn clean install , the whole compilation and packaging work will be done for you.
3. Everything Java: Maven can also run code quality checks, execute test cases and even deploy applications to remote servers, through plugins. Pretty much every possible task you can think of.
3. Goal
A goal is actually just a Java method which does some specific task within your build.
- Maven์์ ํน์ ์์
์ ์ํํ๋ Java Method๋ผ๊ณ ์๊ฐํ๋ฉด ํธํ๋ค.
- ์ค์ Maven Goal์ void๋ฅผ ๋ฆฌํดํ๋
execute method
์ด๋ค.public void execute () {}
- ์ค์ Maven Goal์ void๋ฅผ ๋ฆฌํดํ๋
- ์ข ๋ ์์ธํ ๊ตฌ์กฐ๋ฅผ ์ดํด๋ณด์๋ฉด, ์์ ๊ฐ์ด ~Mojo class์์ ํ๋์ goal(execute method)์ด ์กด์ฌํ๋ ๊ตฌ์กฐ์ด๋ค.
- Mojo: maven plain old java object
์์๋ ๊ธฐ๋ณธ์ ์ผ๋ก Maven๊ณผ ํจ๊ป ๋ฒ๋ค๋ก ์ ๊ณต๋๋ Maven์ ๋ํ์ ์ธ Goal๊ณผ ์ด๋ฅผ ํฌํจํ๊ณ ์๋ ํ๋ฌ๊ทธ์ธ์ด๋ค. ๋ฌผ๋ก ์์ ๋์ ์๋ Maven์์ ์ ๊ณตํ๋ ํ๋ฌ๊ทธ์ธ ์ธ์ 3rd party ํ๋ฌ๊ทธ์ธ๋ ์ฌ์ฉํ ์ ์๋ค.
- Goal ์คํ์ ๋ค์๊ณผ ๊ฐ์ด ๊ฐ๋ฅํ๋ค.
goal ์คํ ๋ฐฉ๋ฒ : mvn <plugin name>:<goal name>
4. Plugin
- ํ๋ ์ด์์ goal์ ์งํฉ์ฒด.
- ๋น์ ํ์๋ฉด, goal์ ๋ฉ์๋์ด๊ณ Plugin์ goal์ ๋ฉ์๋๋ก ๊ฐ์ง๋ ํด๋์ค๋ผ๊ณ ํ ์ ์๋ค.
// failsafe plugin์์ ์๋ goal ์ค๋ช
๋ณด๊ธฐ
mvn <PLUGIN>:help
mvn failsafe:help
// ๊ฒฐ๊ณผ
This plugin has 3 goals:
failsafe:help
Display help information on maven-failsafe-plugin.
Call mvn failsafe:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
failsafe:integration-test
Run integration tests using Surefire.
failsafe:verify
Verify integration tests ran using Surefire.
5. Phase
Going one level higher, Maven offers a neat way to group multiple goals from multiple plugins. This group of goals is called a phase
- 0๊ฐ ~ N๊ฐ์ Goal๋ค์ ํฌํจํ๋ ์ผ๋ จ์ ๊ทธ๋ฃน
- ์๋ฅผ ๋ค์ด
jar
๋ผ๋Goal
์package Phase
์ ์ผ๋ถ์ด๋ค = jar goal is bound to the package phase
Maybe youโre wondering whatโs the point of having this additional grouping of goals in phases?
Well the answer is that the Maven team wanted to make the system as configurable as possible.
But before I explain that fully, we need to go all the way up to the highest level concept which is the build lifecycle.
๊ทธ๋ฆฌ๊ณ ๋ฐ์๋ ๋ํ์ ์ธ Phase์ ๋ํ ์ค๋ช ์ด๋ค.
validate: check if all information necessary for the build is available
compile: compile the source code
test-compile: compile the test source code
test: run unit tests
package: package compiled source code into the distributable format (jar, war, โฆ)
integration-test: process and deploy the package if needed to run integration tests
install: install the package to a local repository
deploy: copy the package to the remote repository
mvn <phase>
๋ช ๋ น์ ์คํํ๋ ๊ฒ์ phase์ ์ง์ ๋ plugin์ ํน์ goal์ ์คํํ๋ ๊ฒ์ด๋ค.- goal์ด ์๋ phase๋ ์๋ค.
- validate, initialize, verify .. ๋ฑ์ด๋ค.
- ์ด๋ค์ ๋ ๋ฆฝ์ ์ผ๋ก ์คํ๋์ง ์๊ณ , lifecycle์ ํตํด์๋ง ์คํ๋๋ค.
- ๋ค์ ๋ช ๋ น์ ์ฌ์ฉํ์ฌ ํน์ Phase์ ๋ฐ์ธ๋ฉ๋ ๋ชจ๋ Goals์ ํด๋น ํ๋ฌ๊ทธ์ธ์ ๋์ดํ ์ ์๋ค.
mvn help:describe -Dcmd=PHASENAME
mvn help:describe -Dcmd=compile
// ๊ฒฐ๊ณผ
compile' is a phase corresponding to this plugin:
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
6. Lifecycle
A build lifecycle is simply an ordered sequence of phases. The idea is that the lifecycle contains everything required for a full build.
- ๋ผ์ดํ์ฌ์ดํด์ ๋จ์ํ Phase์ ์์๊ฐ ์ง์ ๋ ์ํ์ค์ด๋ค = Maven์ด ๋ฏธ๋ฆฌ ์ ์ ํ๊ณ ์๋ ๋น๋ ์์
- ex)
Default(Build) Maven ๋ผ์ดํ์ฌ์ดํด
์ 23๋จ๊ณ๋ก ๊ตฌ์ฑ๋์ด ์์ผ๋ฉฐ validata ๋ฐ initialization์์ install๋ฐ deploy์ ์ด๋ฅด๋ Phase๋ค์ ํฌํจํ๋ค. ๊ทธ๋ฆฌ๊ณ ๊ฐ Phase๋ ํ๋ฌ๊ทธ์ธ์ ํฌํจ๋ 0 ~ N๊ฐ์ goal๊ณผ ๋งคํ๋๋ค.
- ex)
- ๋ฉ์ด๋ธ์ 3๊ฐ์ ํ์ค ๋ผ์ดํ์ฌ์ดํด์ ์ ๊ณตํ๋ค.
- Clean : ๋น๋ ์ ์์ฑ๋์๋ Output์ ์ง์์ค๋ค โ target ํด๋ ์ญ์
- Default(Build) : ์ผ๋ฐ์ ์ธ ๋น๋ ํ๋ก์ธ์ค๋ฅผ ์ํ ๋ชจ๋ธ์ด๋ค.
- Site : ํ๋ก์ ํธ ๋ฌธ์์ ์ฌ์ดํธ ์์ฑ์ ์ํํ๋ค.
When you pass a phase to the Maven command, first all previous phases in the lifecycle get executed, followed by the phase you specified.
- ๋ง์ฝ Maven Command๋ก phase(ex: mvn install)๋ฅผ ์
๋ ฅํ๋ค๋ฉด, ํด๋น phase์ ์ด์ phase๊ฐ ๋ชจ๋ ์์๋๋ก ์คํ๋ ๋ค์ ์
๋ ฅํ phase๊ฐ ์คํ๋๋ค. (validate ~ intstall๊น์ง ์ ์ฒด ์คํ)
- = ๊ฐ๊ฐ์ phase๋ ์์กด ๊ด๊ณ๋ฅผ ๊ฐ์ง๊ณ ์์ด ์ด๋ค phase๋ฅผ ์คํํ๋ฉด ์ด์ ๋จ๊ณ์ phase๊ฐ ๋ชจ๋ ์ํ ๋๋ค.
- ex: ๋น๋ lifecycle์ ๋ง์ง๋ง ๋จ๊ณ์ธ mvn deploy๋ฅผ ์ํํ๋ฉด default lifecycle์ ๋ชจ๋ phase๊ฐ ์คํ๋๋ค.
๐ ์ ๋ฆฌ
๋ค์ ์ต์์ ๊ฐ๋ ์ธ Lifecycle๋ถํฐ ์ ๋ฆฌํด๋ณด์๋ฉด,
Lifecycle
- Maven์ด ์ ์ํด ๋์ ๋น๋ ์์. ์ด 3๊ฐ๊ฐ ์๋ค.(clean, default, site)
- ์์๊ฐ ์๋ phase๋ค์ ๋ชจ์(?)
phase
- lifecycle์ ๊ฐ ๋จ๊ณ.
- ์๋ฅผ ๋ค์ด clean lifecycle์ 3๊ฐ์ phase๋ก ๊ตฌ์ฑ๋์ด ์๋ค. (pre-clean, clean, post-clean).
- ๊ทธ๋ฆฌ๊ณ ๊ฐ phase๋ ์์กด ๊ด๊ณ๋ฅผ ๊ฐ๊ณ ์์ด ์ด๋ค phase๋ฅผ ์คํํ๋ฉด ์ด์ ๋จ๊ณ์ phase๊ฐ ๋ชจ๋ ์ํ๋๋ค.
goal
- ์ค์ ๋ก ์คํ๋๋ ๋ฉ์๋(ํน์ ์คํ ๋จ์).
- ๊ฐ phase๋ 0๊ฐ, 1๊ฐ, ํน์ ๊ทธ ์ด์์ goal์ ์คํํ๋ค.
plugin
- goal๋ค์ ๊ทธ๋ฃน. goal์ด ๋ฉ์๋๋ผ๋ฉด plugin์ ํด๋์ค์ด๋ค. (ํน์ goal์ ํ๋ฌ๊ทธ์ธ์ ํฌํจ๋์ด ์๋ ๋ช ๋ น์ด์ ๋๋ก ์ดํดํ๋ฉด ๋๋ค).
- ์ฌ์ค Maven ์์ฒด๋ ๊ธฐ๋ณธ์ ์ธ ๊ธฐ๋ฅ๋ง์ ๊ฐ์ง๊ณ ์๊ณ , ๋น๋์ ํ์ํ ๋๋ถ๋ถ์ ๊ธฐ๋ฅ๋ค์ ํ๋ฌ๊ทธ์ธ์ ์คํํด์ ์ ๊ณต ๋๋ ํํ์ด๋ค. = ์ฆ phase๋ฅผ ์คํํ๋ฉด ํด๋น phase์ ์ฐ๊ฒฐ๋ ํ๋ฌ๊ทธ์ธ์ goal์ด ์คํ๋๋ ๊ตฌ์กฐ์ด๋ค.