Maven 生命週期和構建原理

       maven是一個非常經典的和通用的項目管理工具,雖然現在熱炒gradle將作爲下一代 項目管理工具來取代maven,但是 由於maven強大和健全的功能,maven還有很強的生命力。

      本文將介紹maven對於項目生命週期的設計以及原理。

讀完本文,你將瞭解到:

一、maven對項目生命週期的抽象--三大項目生命週期

二、maven對項目默認生命週期的抽象

三、maven指令與生命週期階段的關係

四、maven生命週期各個階段的行爲與maven默認行爲

五、maven項目的目錄結構

六、maven爲生命週期階段綁定特定行爲動作的機制即插件原理

一、 maven對項目生命週期的抽象--三大項目生命週期


maven從項目的三個不同的角度,定義了單套生命週期,三套生命週期是相互獨立的,它們之間不會相互影響。

默認構建生命週期(Default Lifeclyle): 該生命週期表示這項目的構建過程,定義了一個項目的構建要經過的不同的階段。

清理生命週期(Clean Lifecycle): 該生命週期負責清理項目中的多餘信息,保持項目資源和代碼的整潔性。一般拿來清空directory(即一般的target)目錄下的文件。

站點管理生命週期(Site Lifecycle) :向我們創建一個項目時,我們有時候需要提供一個站點,來介紹這個項目的信息,如項目介紹,項目進度狀態、項目組成成員,版本控制信息,項目javadoc索引信息等等。站點管理生命週期定義了站點管理過程的各個階段。


             本文只介紹maven項目默認的生命週期,其他兩個生命週期將另起博文介紹。

二、 maven對項目默認生命週期的抽象





如何查看maven對默認生命週期的定義?

    maven將其架構和結構的組織放置到了components.xml 配置文件中,該配置文件的路徑是:

           apache-maven-${version}\lib\maven-core-${version}.jar\META-INFO\plexus\conponents.xml文件中。其中,我們可以看到關於default生命週期XML節點配置信息:

  1. <component>
  2. <role>org.apache.maven.lifecycle.Lifecycle</role>
  3. <implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
  4. <role-hint>default</role-hint>
  5. <configuration>
  6. <id>default</id>
  7. <phases>
  8. <phase>validate</phase>
  9. <phase>initialize</phase>
  10. <phase>generate-sources</phase>
  11. <phase>process-sources</phase>
  12. <phase>generate-resources</phase>
  13. <phase>process-resources</phase>
  14. <phase>compile</phase>
  15. <phase>process-classes</phase>
  16. <phase>generate-test-sources</phase>
  17. <phase>process-test-sources</phase>
  18. <phase>generate-test-resources</phase>
  19. <phase>process-test-resources</phase>
  20. <phase>test-compile</phase>
  21. <phase>process-test-classes</phase>
  22. <phase>test</phase>
  23. <phase>prepare-package</phase>
  24. <phase>package</phase>
  25. <phase>pre-integration-test</phase>
  26. <phase>integration-test</phase>
  27. <phase>post-integration-test</phase>
  28. <phase>verify</phase>
  29. <phase>install</phase>
  30. <phase>deploy</phase>
  31. </phases>
  32. </configuration>
  33. </component>


maven根據一個項目的生命週期的每個階段,將一個項目的生命週期抽象成了如上圖所示的23個階段。而每一個階段應該幹什麼事情由用戶決定。換句話說,maven爲每一個階段設計了接口,你可以爲每一階段自己定義一個接口,進而實現對應階段應該有的行爲。關於如何爲某個生命週期階段綁定自定義的行爲,我將在後面的章節介紹。


、 maven指令與生命週期階段的關係





maven生命週期各個階段的行爲與maven默認行爲

使用過maven的讀者會經常使用這些maven指令:
  1. mvn compile //讓當前項目經歷生命週期中的1-->7 階段 :完成編譯主源代碼編譯
  2. mvn package //讓當前項目經歷生命週期中的1-->17階段 :完成打包
  3. mvn install //讓當前項目經歷生命週期中的1-->22階段 :完成包安裝到本地倉庫
  4. mvn deploy //讓當前生命經歷生命週期中的1-->23階段 :完成包部署到中心庫中

在經歷這些生命週期的階段中,每個階段會理論上會有相應的處理操作。但是,在實際的項目開發過程中, 並不是所有的生命週期階段都是必須的。
然而,在實際的開發過程中,往往我們的項目的一些生命週期的階段不需要相應的行爲,我們只需要關心其中某些重要的生命週期階段而已。下面,請看一下日常開發中,我們需要關注的生命週期階段,即廣大開發人員對項目週期階段處理的約定:

1).應該將resource資源文件準備好,放到指定的target目錄下----process-resources 階段;
2).將java源文件編譯成.class文件,然後將class 文件放置到對應的target目錄下----compile階段;
3).將test類型的resource移動到指定的 target目錄下------process-test-resource階段;
4).將test類型的java 源文件編譯成class文件,然後放置到指定的target目錄下------test-compile階段;
5).運行test測試用例-------test階段;
6).將compile階段編譯的class文件和resource資源打包成jar包或war包--------package階段;
7).將生成的包安裝到本地倉庫中------install階段
8).將生成的包部署到遠程倉庫中-----deploy階段

           由上面的約定可以看出,在大多數情況下,大家關心的項目生命週期階段僅僅是上面的8個而已。跟上面maven對生命週期階段23個的抽象相比,這就少的很多了。

        基於類似的約定,maven默認地爲一些不同類型的maven項目生命週期的階段實現了默認的行爲。

        maven 在設計上將生命週期階段的抽象對應階段應該執行的行爲實現分離開,maven這些實現放到了插件中,這些插件本質上是實現了maven留在各個生命週期階段的接口。關於插件的問題,我將另外寫一篇博文介紹。

如下圖所示,maven針對不同打包類型的maven項目的生命週期階段綁定了對應的默認行爲:

如上圖所示,對於不同的打包格式的項目而言,maven爲特定類型的包格式項目在不同的生命週期階段的默認行爲。

而對於我們經常使用的jar和war包格式的項目而言,maven總共爲其規定了以下幾個生命週期階段的默認行爲:





、 maven項目的目錄結構

well,每個項目工程,都有非常繁瑣的目錄結構,每個目錄都有不同的作用。請記住這一點,目錄的劃分是根據需要來的,每個目錄有其特定的功能。目錄本質上就是一個文件或文件夾路徑而已。那麼,我們換一個思路考慮:一個項目的文件結構需要組織什麼信息呢?讓我們來看一下功能的劃分:


如上圖所示,你會看到maven項目裏不同功能類型的目錄定義以及maven默認的目錄的路徑。

如何修改默認的目錄配置

在maven項目工程對應project的 pom.xml中,在<project>--><build>節點下,你可以指定自己的目錄路徑信息:

  1. <build>
  2. <!-- 目錄信息維護,用戶可以指定自己的目錄路徑 -->
  3. <sourceDirectory>E:\intellis\maven-principle\phase-echo\src\main\java</sourceDirectory>
  4. <scriptSourceDirectory>E:\intellis\maven-principle\phase-echo\src\main\scripts</scriptSourceDirectory>
  5. <testSourceDirectory>E:\intellis\maven-principle\phase-echo\src\test\java</testSourceDirectory>
  6. <outputDirectory>E:\intellis\maven-principle\phase-echo\target\classes</outputDirectory>
  7. <testOutputDirectory>E:\intellis\maven-principle\phase-echo\target\test-classes</testOutputDirectory>
  8. <!-- 注意,對resource而言,可以有很多個resource路徑的配置,你只需要指定對應的路徑是resource即可 -->
  9. <resources>
  10. <resource>
  11. <directory>E:\intellis\maven-principle\phase-echo\src\main\resources</directory>
  12. </resource>
  13. </resources>
  14. <!-- 注意,對resource而言,可以有很多個resource路徑的配置,你只需要指定對應的路徑是resource即可 -->
  15. <testResources>
  16. <testResource>
  17. <directory>E:\intellis\maven-principle\phase-echo\src\test\resources</directory>
  18. </testResource>
  19. </testResources>
  20. <directory>E:\intellis\maven-principle\phase-echo\target</directory>
  21. </build>

請注意:對於maven管理項目工程的生命週期的操作上, 都發生在上述的幾種目錄中。換句話說,實質上,maven的項目管理的整個過程,就是圍繞着對上述幾種文件目錄中內容的操作。


maven爲生命週期階段綁定特定行爲動作的機制(即插件原理)


爲maven生命週期的某些階段綁定特定行爲或動作,簡單點就是調用一段代碼而已,maven將需要執行的邏輯抽象成了一個接口,接口爲 Mojo。Mojo是 Maven Old plain Java Object的簡寫,表示的意思是Mojo是maven的一個簡單的對象。如下圖所示:


maven通過爲某一個項目的生命週期階段綁定若干個Mojo,然後依次執行Mojo.execute()方法,從而實現特定生命週期應該執行的動作。

舉例:比如,對於生命週期階段process-resources,maven默認地爲其綁定了一個Mojo:  org.apache.maven.plugin.resources.ResourcesMojo。

當需要經歷process-resources階段時,maven將會創建一個ResourcesMojo 實例instance,然後調用instance.execute()方法。

  1. @Mojo( name = "resources", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, threadSafe = true )
  2. public class ResourcesMojo
  3. extends AbstractMojo
  4. implements Contextualizable
  5. {
  6. /**
  7. 下面若干個attribute ,maven 讀取pom.xml內的配置信息,這裏的attribute對應着pom.xml裏的配置,如果在這裏聲明瞭,maven在創建Mojo 實例
  8. instance的時候,會將這些值注入到instance內,供Mojo instance使用
  9. */
  10.  /**
  11. * The character encoding scheme to be applied when filtering resources.
  12. */
  13. @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
  14. protected String encoding;
  15. /**
  16. * The output directory into which to copy the resources.
  17. */
  18. @Parameter( defaultValue = "${project.build.outputDirectory}", required = true )
  19. private File outputDirectory;
  20. /**
  21. * The list of resources we want to transfer.
  22. */
  23. @Parameter( defaultValue = "${project.resources}", required = true, readonly = true )
  24. private List<Resource> resources;
  25. /**
  26. *
  27. */
  28. @Parameter( defaultValue = "${project}", required = true, readonly = true )
  29. protected MavenProject project;
  30. /**
  31. * The list of additional filter properties files to be used along with System and project
  32. * properties, which would be used for the filtering.
  33. * <br/>
  34. * See also: {@link ResourcesMojo#filters}.
  35. *
  36. * @since 2.4
  37. */
  38. @Parameter( defaultValue = "${project.build.filters}", readonly = true )
  39. protected List<String> buildFilters;
  40. /**
  41. * The list of extra filter properties files to be used along with System properties,
  42. * project properties, and filter properties files specified in the POM build/filters section,
  43. * which should be used for the filtering during the current mojo execution.
  44. * <br/>
  45. * Normally, these will be configured from a plugin's execution section, to provide a different
  46. * set of filters for a particular execution. For instance, starting in Maven 2.2.0, you have the
  47. * option of configuring executions with the id's <code>default-resources</code> and
  48. * <code>default-testResources</code> to supply different configurations for the two
  49. * different types of resources. By supplying <code>extraFilters</code> configurations, you
  50. * can separate which filters are used for which type of resource.
  51. */
  52. @Parameter
  53. protected List<String> filters;
  54. /**
  55. * If false, don't use the filters specified in the build/filters section of the POM when
  56. * processing resources in this mojo execution.
  57. * <br/>
  58. * See also: {@link ResourcesMojo#buildFilters} and {@link ResourcesMojo#filters}
  59. *
  60. * @since 2.4
  61. */
  62. @Parameter( defaultValue = "true" )
  63. protected boolean useBuildFilters;
  64. /**
  65. *
  66. */
  67. @Component( role = MavenResourcesFiltering.class, hint = "default" )
  68. protected MavenResourcesFiltering mavenResourcesFiltering;
  69. /**
  70. *
  71. */
  72. @Parameter( defaultValue = "${session}", required = true, readonly = true )
  73. protected MavenSession session;
  74. /**
  75. * Expression preceded with the String won't be interpolated
  76. * \${foo} will be replaced with ${foo}
  77. *
  78. * @since 2.3
  79. */
  80. @Parameter( property = "maven.resources.escapeString" )
  81. protected String escapeString;
  82. /**
  83. * Overwrite existing files even if the destination files are newer.
  84. *
  85. * @since 2.3
  86. */
  87. @Parameter( property = "maven.resources.overwrite", defaultValue = "false" )
  88. private boolean overwrite;
  89. /**
  90. * Copy any empty directories included in the Resources.
  91. *
  92. * @since 2.3
  93. */
  94. @Parameter( property = "maven.resources.includeEmptyDirs", defaultValue = "false" )
  95. protected boolean includeEmptyDirs;
  96. /**
  97. * Additional file extensions to not apply filtering (already defined are : jpg, jpeg, gif, bmp, png)
  98. *
  99. * @since 2.3
  100. */
  101. @Parameter
  102. protected List<String> nonFilteredFileExtensions;
  103. /**
  104. * Whether to escape backslashes and colons in windows-style paths.
  105. *
  106. * @since 2.4
  107. */
  108. @Parameter( property = "maven.resources.escapeWindowsPaths", defaultValue = "true" )
  109. protected boolean escapeWindowsPaths;
  110. /**
  111. * <p>
  112. * Set of delimiters for expressions to filter within the resources. These delimiters are specified in the
  113. * form 'beginToken*endToken'. If no '*' is given, the delimiter is assumed to be the same for start and end.
  114. * </p><p>
  115. * So, the default filtering delimiters might be specified as:
  116. * </p>
  117. * <pre>
  118. * <delimiters>
  119. * <delimiter>${*}</delimiter>
  120. * <delimiter>@</delimiter>
  121. * </delimiters>
  122. * </pre>
  123. * <p>
  124. * Since the '@' delimiter is the same on both ends, we don't need to specify '@*@' (though we can).
  125. * </p>
  126. *
  127. * @since 2.4
  128. */
  129. @Parameter
  130. protected List<String> delimiters;
  131. /**
  132. * @since 2.4
  133. */
  134. @Parameter( defaultValue = "true" )
  135. protected boolean useDefaultDelimiters;
  136. /**
  137. * <p>
  138. * List of plexus components hint which implements {@link MavenResourcesFiltering#filterResources(MavenResourcesExecution)}.
  139. * They will be executed after the resources copying/filtering.
  140. * </p>
  141. *
  142. * @since 2.4
  143. */
  144. @Parameter
  145. private List<String> mavenFilteringHints;
  146. /**
  147. * @since 2.4
  148. */
  149. private PlexusContainer plexusContainer;
  150. /**
  151. * @since 2.4
  152. */
  153. private List<MavenResourcesFiltering> mavenFilteringComponents = new ArrayList<MavenResourcesFiltering>();
  154. /**
  155. * stop searching endToken at the end of line
  156. *
  157. * @since 2.5
  158. */
  159. @Parameter( property = "maven.resources.supportMultiLineFiltering", defaultValue = "false" )
  160. private boolean supportMultiLineFiltering;
  161. public void contextualize( Context context )
  162. throws ContextException
  163. {
  164. plexusContainer = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
  165. }
  166. public void execute()
  167. throws MojoExecutionException
  168. {
  169. try
  170. {
  171. if ( StringUtils.isEmpty( encoding ) && isFilteringEnabled( getResources() ) )
  172. {
  173. getLog().warn( "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
  174. + ", i.e. build is platform dependent!" );
  175. }
  176. //獲取資源文件過濾器配置
  177. List filters = getCombinedFiltersList();
  178. //根據現有配置信息創建Resources處理器對象實例
  179. MavenResourcesExecution mavenResourcesExecution =
  180. new MavenResourcesExecution( getResources(), getOutputDirectory(), project, encoding, filters,
  181. Collections.<String>emptyList(), session );
  182. //windows路徑處理
  183. mavenResourcesExecution.setEscapeWindowsPaths( escapeWindowsPaths );
  184. // never include project build filters in this call, since we've already accounted for the POM build filters
  185. // above, in getCombinedFiltersList().
  186. mavenResourcesExecution.setInjectProjectBuildFilters( false );
  187. mavenResourcesExecution.setEscapeString( escapeString );
  188. mavenResourcesExecution.setOverwrite( overwrite );
  189. mavenResourcesExecution.setIncludeEmptyDirs( includeEmptyDirs );
  190. mavenResourcesExecution.setSupportMultiLineFiltering( supportMultiLineFiltering );
  191. // if these are NOT set, just use the defaults, which are '${*}' and '@'.
  192. if ( delimiters != null && !delimiters.isEmpty() )
  193. {
  194. LinkedHashSet<String> delims = new LinkedHashSet<String>();
  195. if ( useDefaultDelimiters )
  196. {
  197. delims.addAll( mavenResourcesExecution.getDelimiters() );
  198. }
  199. for ( String delim : delimiters )
  200. {
  201. if ( delim == null )
  202. {
  203. // FIXME: ${filter:*} could also trigger this condition. Need a better long-term solution.
  204. delims.add( "${*}" );
  205. }
  206. else
  207. {
  208. delims.add( delim );
  209. }
  210. }
  211. mavenResourcesExecution.setDelimiters( delims );
  212. }
  213. if ( nonFilteredFileExtensions != null )
  214. {
  215. mavenResourcesExecution.setNonFilteredFileExtensions( nonFilteredFileExtensions );
  216. }
  217. mavenResourcesFiltering.filterResources( mavenResourcesExecution );
  218. //執行Resource文件拷貝
  219. executeUserFilterComponents( mavenResourcesExecution );
  220. }
  221. catch ( MavenFilteringException e )
  222. {
  223. throw new MojoExecutionException( e.getMessage(), e );
  224. }
  225. }
  226. /**
  227. * @since 2.5
  228. */
  229. protected void executeUserFilterComponents( MavenResourcesExecution mavenResourcesExecution )
  230. throws MojoExecutionException, MavenFilteringException
  231. {
  232. if ( mavenFilteringHints != null )
  233. {
  234. for ( Iterator ite = mavenFilteringHints.iterator(); ite.hasNext(); )
  235. {
  236. String hint = (String) ite.next();
  237. try
  238. {
  239. mavenFilteringComponents.add(
  240. (MavenResourcesFiltering) plexusContainer.lookup( MavenResourcesFiltering.class.getName(),
  241. hint ) );
  242. }
  243. catch ( ComponentLookupException e )
  244. {
  245. throw new MojoExecutionException( e.getMessage(), e );
  246. }
  247. }
  248. }
  249. else
  250. {
  251. getLog().debug( "no use filter components" );
  252. }
  253. if ( mavenFilteringComponents != null && !mavenFilteringComponents.isEmpty() )
  254. {
  255. getLog().debug( "execute user filters" );
  256. for ( MavenResourcesFiltering filter : mavenFilteringComponents )
  257. {
  258. filter.filterResources( mavenResourcesExecution );
  259. }
  260. }
  261. }
  262. protected List<String> getCombinedFiltersList()
  263. {
  264. if ( filters == null || filters.isEmpty() )
  265. {
  266. return useBuildFilters ? buildFilters : null;
  267. }
  268. else
  269. {
  270. List<String> result = new ArrayList<String>();
  271. if ( useBuildFilters && buildFilters != null && !buildFilters.isEmpty() )
  272. {
  273. result.addAll( buildFilters );
  274. }
  275. result.addAll( filters );
  276. return result;
  277. }
  278. }
  279. /**
  280. * Determines whether filtering has been enabled for any resource.
  281. *
  282. * @param resources The set of resources to check for filtering, may be <code>null</code>.
  283. * @return <code>true</code> if at least one resource uses filtering, <code>false</code> otherwise.
  284. */
  285. private boolean isFilteringEnabled( Collection<Resource> resources )
  286. {
  287. if ( resources != null )
  288. {
  289. for ( Resource resource : resources )
  290. {
  291. if ( resource.isFiltering() )
  292. {
  293. return true;
  294. }
  295. }
  296. }
  297. return false;
  298. }
  299. }

上面只是介紹了Maven生命週期階段綁定執行代碼的基本模式,由於maven的生命週期衆多,並且每個生命週期內有可能綁定多個Mojo,如果使用上述的模式簡單關聯的話,會顯得結構組織很亂。

maven會根據Mojo功能的劃分,將具有相似功能的Mojo放到一個插件中。並且某一個特定的Mojo能實現的功能稱爲 goal,即目標,表明該Mojo能實現什麼目標。


例如,我們項目生命週期有兩個階段:compile 和 test-compile,這兩階段都是需要將java源代碼編譯成class文件中,相對應地,compile和test-compiler分別被綁定到了org.apache.maven.plugin.compiler.CompilerMojo 和org.apache.maven.plugin.compiler.TestCompilerMojo上:

如何查看maven各個生命週期階段和插件的綁定情況

maven默認實現上,會爲各個常用的生命週期根據約定綁定特定的插件目標。maven將這些配置放置到了:

apache-maven-${version}\lib\maven-core-${version}.jar\META-INFO\plexus\default-binds.xml文件中,針對不同打包類型的項目,其默認綁定情況也會不一樣,我們先看一下常用的jar包類型和war包類型的項目默認綁定情況:


  1. <!-- jar包格式的項目生命週期各個階段默認綁定情況 -->
  2. <component>
  3. <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
  4. <role-hint>jar</role-hint>
  5. <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
  6. <configuration>
  7. <lifecycles>
  8. <lifecycle>
  9. <id>default</id>
  10. <!-- START SNIPPET: jar-lifecycle -->
  11. <phases>
  12. <!-- 插件綁定的格式: <plugin-groupid>:<plugin-artifactid>:<version>:goal -->
  13. <process-resources>
  14. org.apache.maven.plugins:maven-resources-plugin:2.6:resources
  15. </process-resources>
  16. <compile>
  17. org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
  18. </compile>
  19. <process-test-resources>
  20. org.apache.maven.plugins:maven-resources-plugin:2.6:testResources
  21. </process-test-resources>
  22. <test-compile>
  23. org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile
  24. </test-compile>
  25. <test>
  26. org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test
  27. </test>
  28. <package>
  29. org.apache.maven.plugins:maven-jar-plugin:2.4:jar
  30. </package>
  31. <install>
  32. org.apache.maven.plugins:maven-install-plugin:2.4:install
  33. </install>
  34. <deploy>
  35. org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
  36. </deploy>
  37. </phases>
  38. <!-- END SNIPPET: jar-lifecycle -->
  39. </lifecycle>
  40. </lifecycles>
  41. </configuration>
  42. </component>
  43. <!-- war包格式的項目生命週期各個階段默認綁定情況 -->
  44. <component>
  45. <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
  46. <role-hint>war</role-hint>
  47. <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
  48. <configuration>
  49. <lifecycles>
  50. <lifecycle>
  51. <id>default</id>
  52. <!-- START SNIPPET: war-lifecycle -->
  53. <phases>
  54. <process-resources>
  55. org.apache.maven.plugins:maven-resources-plugin:2.6:resources
  56. </process-resources>
  57. <compile>
  58. org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
  59. </compile>
  60. <process-test-resources>
  61. org.apache.maven.plugins:maven-resources-plugin:2.6:testResources
  62. </process-test-resources>
  63. <test-compile>
  64. org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile
  65. </test-compile>
  66. <test>
  67. org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test
  68. </test>
  69. <package>
  70. org.apache.maven.plugins:maven-war-plugin:2.2:war
  71. </package>
  72. <install>
  73. org.apache.maven.plugins:maven-install-plugin:2.4:install
  74. </install>
  75. <deploy>
  76. org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
  77. </deploy>
  78. </phases>
  79. <!-- END SNIPPET: war-lifecycle -->
  80. </lifecycle>
  81. </lifecycles>
  82. </configuration>
  83. </component>

如果你想查看當前maven有多少插件,每個插件都幹了什麼,你可以訪問 maven plugin主頁瞭解 : http://maven.apache.org/plugins/index.html




寫在最後

本文旨在向讀者介紹maven默認生命週期的工作機制,以及maven在項目構建過程中的基本原理和機制。

本文介紹的比較寬泛,還沒有深入到maven插件底層,隨後一篇博文將會詳細介紹插件,解析插件的工作原理,分析當前maven默認定義的插件,並最終自己定義插件完成特定功能,敬請關注!

由於本人技術有限,如果本人有任何錯誤和紕漏,請讀者慷慨指出,共同學習,共同進步!


2016.1.15














發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章