天天看点

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