﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-qqjianyue代码工-随笔分类-appfuse2 and maven2</title><link>http://www.blogjava.net/jianyue/category/34386.html</link><description>砌java代码</description><language>zh-cn</language><lastBuildDate>Thu, 22 Sep 2011 13:48:58 GMT</lastBuildDate><pubDate>Thu, 22 Sep 2011 13:48:58 GMT</pubDate><ttl>60</ttl><item><title>maven 概念与实践 phase, goal, plugin</title><link>http://www.blogjava.net/jianyue/archive/2011/09/22/359233.html</link><dc:creator>Qzi</dc:creator><author>Qzi</author><pubDate>Thu, 22 Sep 2011 02:01:00 GMT</pubDate><guid>http://www.blogjava.net/jianyue/archive/2011/09/22/359233.html</guid><wfw:comment>http://www.blogjava.net/jianyue/comments/359233.html</wfw:comment><comments>http://www.blogjava.net/jianyue/archive/2011/09/22/359233.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jianyue/comments/commentRss/359233.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jianyue/services/trackbacks/359233.html</trackback:ping><description><![CDATA[参考这篇文章：<a href="http://blog.csdn.net/bluishglc/article/details/6632280">http://blog.csdn.net/bluishglc/article/details/6632280</a>&nbsp;<br />一。Maven的执行方式<br /><div><span style="font-family: Arial; line-height: 26px; ">maven对构建(build)的过程进行了抽象和定义，这个过程被称为构建的生命周期(lifecycle)。生命周期(lifecycle)由多个阶段(phase)组成,每个阶段(phase)会挂接一到多个goal。goal是maven里定义任务的最小单元，goal分为两类，一类是绑定phase的，就是执行到某个phase，那么这个goal就会触发，另外一类不绑定，就是单独任务，这就相当于ant里的target。<br /></span></div>1。以phase来构建<br />例如：<br />mvn clean<br />mvn compile<br />mvn test<br />mvn package<br />表明maven会执行到某个生命周期(lifecycle)的某个阶段(phase)<br />这个phase以及它前面所有phase绑定的目标(goal)都会执行， 每个phase都会邦定maven默认的goal或者没有goal， 或者自定义的goal。<br />也可以通过传入参数跳过(skip)某些phase，例如：<br /><div><span style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; font-size: 12px; line-height: 18px; "><span style="color: black; ">mvn&nbsp;install&nbsp;-Dmaven.test.skip=</span><span style="color: #7f0055; font-weight: bold; ">true</span></span></div><br />1。以goal来构建<br />这类就是没有绑定phase的goal，但是这类goal却通常会有个执行前提，就是project必须执行到某个phase，<br />那么执行这个goal，其实也会触发maven执行到前提要求的phase。<br />例如jetty:run是个非绑定phase的goal，它的前提是<span class="Apple-style-span" style="font-family: Arial; line-height: 26px; ">test-compile，这个前提是由plugin的代码逻辑制定的</span><br /><br /><div><div>/**</div><div>&nbsp;* @goal run</div><div>&nbsp;* @requiresDependencyResolution runtime</div><div><span style="color: #0000ff; ">&nbsp;* @execute phase="test-compile"</span></div><div>&nbsp;* @description Runs jetty6 directly from a maven project</div><div>&nbsp;*/</div><div>public class Jetty6RunMojo extends AbstractJettyRunMojo</div><div>{</div><div>&nbsp; &nbsp; ...</div><div>}<br /></div></div>二。Maven lifecycle, phase概览<br /><span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px; ">Maven预设了三个Lifecycle ，各包含了下列Phases.</span><div><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px; "><ol style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; padding-left: 20px; "><li>Clean Lifecycle<ul style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; padding-left: 20px; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">pre-clean</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">clean</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">post-clean</li></ul></li><li>Default Lifecycle<ul style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; padding-left: 20px; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">validate</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">initialize</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">generate-sources</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">process-sources</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">generate-resources</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">process-resources</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">compile</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">process-classes</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">generate-test-sources</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">process-test-sources</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">process-test-resources</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">test-compile</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">process-test-classes</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">test</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">prepare-package</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">package</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">pre-integration-test</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">integration-test</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">post-integration-test</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">verify</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">install</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">deploy</li></ul></li><li>Site Lifecycle<ul style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; padding-left: 20px; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">pre-site</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">site</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">post-site</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">site-deploy</li></ul></li></ol></span></div><img src ="http://www.blogjava.net/jianyue/aggbug/359233.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jianyue/" target="_blank">Qzi</a> 2011-09-22 10:01 <a href="http://www.blogjava.net/jianyue/archive/2011/09/22/359233.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>maven phases</title><link>http://www.blogjava.net/jianyue/archive/2008/09/16/229207.html</link><dc:creator>Qzi</dc:creator><author>Qzi</author><pubDate>Tue, 16 Sep 2008 09:06:00 GMT</pubDate><guid>http://www.blogjava.net/jianyue/archive/2008/09/16/229207.html</guid><wfw:comment>http://www.blogjava.net/jianyue/comments/229207.html</wfw:comment><comments>http://www.blogjava.net/jianyue/archive/2008/09/16/229207.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jianyue/comments/commentRss/229207.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jianyue/services/trackbacks/229207.html</trackback:ping><description><![CDATA[<ul>
    <li><strong>validate</strong>: validate the project is correct and all necessary information is available
    <li><strong>compile</strong>: compile the source code of the project
    <li><strong>test</strong>: test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
    <li><strong>package</strong>: take the compiled code and package it in its distributable format, such as a JAR.
    <li><strong>integration-test</strong>: process and deploy the package if necessary into an environment where integration tests can be run
    <li><strong>verify</strong>: run any checks to verify the package is valid and meets quality criteria
    <li><strong>install</strong>: install the package into the local repository, for use as a dependency in other projects locally
    <li><strong>deploy</strong>: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects. </li>
</ul>
<p>There are two other Maven lifecycles of note beyond the <em>default</em> list above. They are</p>
<ul>
    <li><strong>clean</strong>: cleans up artifacts created by prior builds </li>
</ul>
<ul>
    <li><strong>site</strong>: generates site documentation for this project </li>
</ul>
<p>官网文章：<a href="http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html">http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html</a></p>
<img src ="http://www.blogjava.net/jianyue/aggbug/229207.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jianyue/" target="_blank">Qzi</a> 2008-09-16 17:06 <a href="http://www.blogjava.net/jianyue/archive/2008/09/16/229207.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>