天天看點

maven 中的 goal 是什麼maven 中的 goal 是什麼

maven 中的 goal 是什麼

maven 中包含三個生命周期,參考 《Maven 生命周期(需了解)》

每個生命周期包含了多個步驟(phase),而 goal 則是綁定到 phase 上的,每一個 phase 都對應 1 個或多個 goal。

goal 是存在于 maven plugin 中,是以,大多數的 maven 功能實際上是存在于插件中,一個 maven 插件提供了一組可以被運作的 goal。

之間的如下 所示:

maven 中的 goal 是什麼maven 中的 goal 是什麼

maven 中可以通過下面的指令格式運作 goal:

mvn [plugin-name]:[goal-name]

比如:

mvn compiler:compile,運作 compiler 插件中的 compile goal。

事實上 compiler:compile.,正是對應于 compile phase 的,即運作 compile phase 就等于運作了 mvn compiler:compile.

在 eclipse 中可以配置運作 maven 中指定的 goal。

maven 中的 goal 是什麼maven 中的 goal 是什麼

phase 和 goal 的不同在于:

運作某個 phase 的時,必須把生命周期中的所有的前置 phase 都會運作一遍。

而運作 goal,可以脫離生命周期這個概念,通過 maven 插件,單獨的運作某個 goal 或一組 goal。

參考:

http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

https://stackoverflow.com/questions/16205778/what-are-maven-goals-and-phases-and-what-is-their-difference