<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Solution Hacker &#187; maven</title>
	<atom:link href="http://www.solutionhacker.com/tag/maven/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.solutionhacker.com</link>
	<description>This blog provides solutions for enterpreneurs!</description>
	<lastBuildDate>Wed, 04 Aug 2010 11:37:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Wiring up Flex, Mate, BlazeDS, Spring, Hibernate and MySQL with Maven 2 &#8211; Part 1</title>
		<link>http://www.solutionhacker.com/uncategorized/wiring-up-flex-mate-blazeds-spring-hibernate-and-mysql-with-maven-2/</link>
		<comments>http://www.solutionhacker.com/uncategorized/wiring-up-flex-mate-blazeds-spring-hibernate-and-mysql-with-maven-2/#comments</comments>
		<pubDate>Thu, 25 Dec 2008 10:50:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[2.1. Develop Your Team]]></category>
		<category><![CDATA[2.2. Build Your Site]]></category>
		<category><![CDATA[5. Fun]]></category>
		<category><![CDATA[6. Uncategorized]]></category>
		<category><![CDATA[AMF]]></category>
		<category><![CDATA[application stack]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[build process]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[jetty plugin]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/?p=199</guid>
		<description><![CDATA[Introduction This article is written on top of the great work that&#160;Sébastien Arbogast has done. He has written 3 articles that showed you how to wire up Flex, BlazeDS, Spring, Hibernate and MySQL with Maven as build process. I have included his articles below as your reference. The Flex, Spring, and BlazeDS full stack – [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>This article is written on top of the great work that&#160;<strong>Sébastien Arbogast </strong>has done. He has written 3 articles that showed you how to wire up Flex, BlazeDS, Spring, Hibernate and MySQL with Maven as build process. I have included his articles below as your reference.</p>
<ol>
<li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt1.html">The Flex, Spring, and BlazeDS full stack – Part 1: Creating a Flex module</a></li>
<li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt2.html">The Flex, Spring and BlazeDS full stack – Part 2: Writing the to-do list server</a></li>
<li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt3.html">The Flex, Spring and BlazeDS full stack – Part 3: Putting the application together</a></li>
</ol>
<p>I have found Sebastien&#8217;s work as a good foundation for my own project. To contribute back to the community, I will write a series of articles to show you how can customize and extend the todolist sample.</p>
<p><u>What is in the Part 1 of the series&#8230;</u></p>
<ol>
<li>Enhancements on the <strong>Maven </strong>build process
<ul>
<li>Leverage <strong>RSL </strong>to factor our the framework swc, so the size of the application swf will be reduced. Apart from that, I also take advantage of <strong>Flash Player Cache</strong> that is available after version 9 update 3 to cache the framework libraries.</li>
<li>Clean up the Flex and <strong>BlazeDS </strong>dependencies in POM as the latest version of the sdk is available and the BlazeDS dependencies are officially available.</li>
<li>Include some common reports for maven site generation</li>
<li>Embed <strong>Jetty</strong> web server in the build process for quick deployment and testing</li>
</ul>
</li>
<li>Document how to get the sample up on <strong>Eclipse </strong>for development<strong><br />
    </strong></li>
<li>Use <strong>Mate </strong>as Flex framework
<ul>
<li>Restructure ToDoList sample to leverage Mate framework</li>
<li>Factor out Mate as RSL and integrate it with Maven build process via Flex-mojo plugin.</li>
</ul>
</li>
</ol>
<p><u>What are in the coming articles&#8230;</u></p>
<ol>
<li>In part 2 of this series, I will show you how to use flex-mojo to build a modular Flex application.</li>
<li>In part 3 of this series, I will show you how to test your flex app via FlexUnit (Unit test) and FlexMonkey (Functional test)</li>
<li>In part 4 or this series, I will work on server side. I am planning to add monitoring, caching and security to the server side.</li>
</ol>
<p><span id="more-199"></span><!--more--></p>
<h2><!--more-->Review &#8220;ToDoList&#8221; sample</h2>
<p>Before I start my journey, let me highlight what Sebastien has done first:</p>
<ol>
<li>Sebastien&#8217;s sample demonstrates how to use Maven as a build process. There are 3 parts or subprojects in his sample. They are:
<ul>
<li><strong>todolist-config</strong> (configuration files shared by other subprojects)</li>
<li><strong>todolist-ria </strong>(Flex frontend)</li>
<li><strong>todolist-web</strong> (Server side that supports the Frontend)</li>
</ul>
</li>
<li>All these subprojects are considered as <strong>modules </strong>of the main project (root POM). Finally, they are combined together into war artifact and ready to deploy to Tomcat or other J2EE webapp server.</li>
<li>Flex frontend and backend communicate through a binary RPC protocol &#8211; <strong>AMF</strong>. AMF is considered to be the simplest and fastest remoting approach available in Flex. Recently, Adobe has released BlazeDS as an open source implementation of AMF spec. In this sample, <strong>BlazeDS </strong>is used. To use BlazeDS, there are few things you need to do:
<ul>
<li>Externalize your POJO service via BlazeDS. This sample shows you how to integrate BlazeDS with Spring</li>
<li>Make BlazeDS endpoints availabe to the Net via Servlet.</li>
<li>Have frontend and backend shared the same BlazeDS configuration files.</li>
</ul>
</li>
<li>In this sample, you can also find out how to use <strong>flex-mojo</strong> maven plugin to compile the Flex frontend code into swf. Apart from <a href="http://docs.flex-mojos.info/flex-compiler-mojo/compile-swf-mojo.html">flex-mojo plugin</a>, there are other two good plugins worth to mention:
<ul>
<li><strong>maven-assembly-plugin </strong>- can be used to bundle all the files under a directory into a zip file. It is used by todolist-config to bundle all the configuration files (<strong>service-config.xml </strong>and <strong>remoting-config.xml</strong>) into a zip during the <strong>package </strong>phase.</li>
<li><strong>maven-dependency-plugin</strong><strong> &#8211; </strong>can be used to unpack the zip file and move to the place you want. It is used by todolist-web to unpack the config zip during the <strong>generate-resources</strong> phase.</li>
</ul>
</li>
</ol>
<h2>Enhancements on maven POM</h2>
<p>I have modified the sample&#8217;s maven pom as follows:</p>
<ul>
<li>Link to new repository &#8220;<strong>Sonatype Forge</strong>&#8221; in the root POM. So, I can use the new version of flex-mojo and simplify the todolist-ria adobe framework dependencies. Apart from that, I also take away the private repository from Sebastein because BlazeDS libraries are available in official maven repository (Note: The BlazeDS libraries available in official maven repo are in version 3.0 instead of 3.0.0.544. So, you need to modify the webapp pom correspondingly).</li>
</ul>
<blockquote>
<p>&#160;&#160;&#160; &lt;repositories&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;repository&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;id&gt;flex-mojos-repository&lt;/id&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;url&gt;http://svn.sonatype.org/flexmojos/repository/&lt;/url&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;releases&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;enabled&gt;true&lt;/enabled&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/releases&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;snapshots&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;enabled&gt;false&lt;/enabled&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/snapshots&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/repository&gt;<br />
&#160;&#160;&#160; &lt;/repositories&gt;</p>
<p>&#160;&#160;&#160; &lt;pluginRepositories&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;pluginRepository&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;id&gt;flex-mojos-repository&lt;/id&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;url&gt;http://svn.sonatype.org/flexmojos/repository/&lt;/url&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;releases&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;enabled&gt;true&lt;/enabled&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/releases&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;snapshots&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;enabled&gt;false&lt;/enabled&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/snapshots&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/pluginRepository&gt;<br />
&#160;&#160;&#160; &lt;/pluginRepositories&gt;</p>
</blockquote>
<ul>
<li>Because I link to Sonatype repository, I can have my todolist-ria depends on one flex-framework pom dependency instead of all the swc dependencies. Note that the pom dependency is a way to factor out all the adobe swc dependencies that makes your pom easier to maintain.</li>
</ul>
<blockquote>
<p>&#160;&#160;&#160; &#160;&#160;&#160; &lt;dependency&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;groupId&gt;com.adobe.flex.framework&lt;/groupId&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;artifactId&gt;flex-framework&lt;/artifactId&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;version&gt;3.1.0.2710&lt;/version&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;type&gt;pom&lt;/type&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &lt;/dependency&gt;</p>
</blockquote>
<ul>
<li>I include mysql driver as dependency in my webapp pom. I think it is cleaner to bundle it in war. I have also added <strong>jetty plugin</strong> in the POM so you have a web server embedded in the build process. With this, you can run this sample application right after you check it out from svn (assume you have maven 2 installed). To start jetty, you can issue the following maven command under your webapp project.</li>
</ul>
<blockquote>
<p>project_root&gt; mvn clean install<br />
project_root/jp-web&gt; mvn jetty:run-war</p>
</blockquote>
<ul>
<li>I have included some reports that will be shown after site generation. You may not be able to do <strong>mvn site-deploy </strong>because it is linked to my web hosting site. However, you can modify it for your own sake.</li>
</ul>
<h2>Get the sample up on Eclipse</h2>
<p>To develop on Eclipse, you can follow the steps below:</p>
<ol>
<li>Create Eclipse project file via running the command below at the project root. This will create 2 eclipse projects. One for todolist-ria and one for the webapp. You noticed that I use the <strong>-Declipse.downloadSource=true</strong> to include the source files of my dependencies in my eclipse project. Therefore, I can get to the source code if needed.</li>
</ol>
<blockquote>
<p>mvn -Declipse.downloadSource=true eclipse:eclipse</p>
</blockquote>
<ol>
<li>Import the projects into Eclipse</li>
<li>Add new variable<strong> M2_REPO</strong> and set it equals to<strong> [home]/.m2/repository</strong></li>
<li>If you have installed <strong>Flex Builder plugin</strong> to your Eclipse, you can Add <strong>Flex Project Nature</strong> to the todolist-ria project.
<ul>
<li>Select Application Server Type: J2EE</li>
<li>Put check on &#8220;Use remote object access service&#8221; with LiveCycle Data Service selected.</li>
<li>Set up the path. I have my tomcat installed under C:\tools with default <strong>8080 </strong>as port. You should make the changes if you installed it differently.</li>
<li><img src="http://www.solutionhacker.com/wp-content/uploads/image/flexEclipse1.JPG" style="width: 531px; height: 284px;" alt="" /></li>
<li>Remove the generated <strong>main.mxml</strong> under the src folder.</li>
<li>Set <strong>index.mxml </strong>under src folder as default Flex application file to run.</li>
<li>Use <strong>Default Flex SDK </strong>in Flex Compiler Configuration instead of Server Flex SDK</li>
<li>Right click and select <strong>Recreate HTML Template</strong> if you see error.</li>
<li>After all these, you have configured your Flex application pointing to the webapp server and sharing the BlazeDS configuration files. You can verify in Flex Compiler Configuration&#8217;s Additional Compiler Parameters. See whether you see this: <strong>-services &#8220;C:\tools\tomcat-6.0.16\webapps\jp\WEB-INF\flex\services-config.xml&#8221; -locale en_US</strong></li>
<li>Move the war to your tomcat&#8217;s webapp folder and start it under remote debugging setting. If you are using window, set<strong> DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8787,suspend=n</strong> under your bin/catalina.bat.</li>
<li>Start your webapp via bin/startup.bat</li>
<li>Put breakpoint under <strong>TodoServiceImpl</strong> save method and start remote debugger on localhost:8787</li>
<li>Right click the<strong> index.mxml</strong> and Run As Flex Application.</li>
<li>Add a new entry and save it on the flex app. <img onclick="grin(':razz:');" alt=":razz:" src="../../../../../wp-includes/images/smilies/icon_razz.gif" /> You should see your remote debugger halt at the breakpoint for you to debug.</li>
<li>Now you can change your flex code and test it out without leaving your Eclipse. However, if you modify the service in webapp, you need to run &#8220;<strong>mvn clean install</strong>&#8221; and deploy the war to the tomcat before your flex code can call your server-side code via <strong>AMF</strong>.</li>
</ul>
</li>
</ol>
<h2>Use Mate as Framework</h2>
<p>If you are not familiar with Mate, click the image below that moves you to a nice presentation.</p>
<p>&#160;<a href="http://mate.asfusion.com/assets/content//presentations/360_max_presentation.pdf"><img src="http://www.solutionhacker.com/wp-content/uploads/image/mate1.JPG" style="width: 589px; height: 339px;" alt="" /></a></p>
<p><u>What did I do to restructure the todolist sample to make it Mate app?</u></p>
<ol>
<li>&#160;</li>
</ol>
<h2>Download</h2>
<p>I have made my work available at: <a href="http://www.solutionhacker.com/wp-content/uploads/todolist-jp-modified.zip">www.solutionhacker.com/wp-content/uploads/todolist-jp-modified.zip</a></p>
<h2>Reference</h2>
<p>Below are the references I used for the article:</p>
<ol>
<li><a href="http://docs.flex-mojos.info/flex-compiler-mojo/compile-swf-mojo.html">Flex mojo compiler user guide</a></li>
<li><a href="http://blog.flex-mojos.info/2008/06/04/scopes/">Flex mojo dependency scope rules</a></li>
<li><a href="http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:Flex_3_RSLs">Flex 3 feature introduction: Flex 3 RSL</a></li>
<li><a href="http://www.adobe.com/devnet/flex/articles/flash_player_cache.html">Improving Flex application performance using Flash Player Cache</a></li>
<li><a href="http://fna.googlecode.com/svn/trunk/fna/site/mvn_archetypes/index.html">FNA archetype projects&#160;</a></li>
</ol>
<p>&#160;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/uncategorized/wiring-up-flex-mate-blazeds-spring-hibernate-and-mysql-with-maven-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Build your project via Maven 2</title>
		<link>http://www.solutionhacker.com/implement-your-idea/build-your-website/build-your-project-via-maven-2/</link>
		<comments>http://www.solutionhacker.com/implement-your-idea/build-your-website/build-your-project-via-maven-2/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 11:12:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[2.2. Build Your Site]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[build process]]></category>
		<category><![CDATA[configuration management]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[POM]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/?p=195</guid>
		<description><![CDATA[POM demysterified POM lets you to tell maven the &#8220;what&#8221; and maven knows the &#8220;how&#8221;. Put it in another way, POM gives you an abstraction layer over your build process to make things more explicit, more standard and easier to follow. There are several key elements in POM that I want to talk about. Below [...]]]></description>
			<content:encoded><![CDATA[<h2>POM demysterified</h2>
<p>POM lets you to tell maven the<strong> &#8220;what&#8221; </strong>and maven knows the &#8220;<strong>how&#8221;</strong>. Put it in another way, POM gives you an abstraction layer over your build process to make things more explicit, more standard and easier to follow. There are several key elements in POM that I want to talk about. Below is a nice diagram I borrowed and it shows you what information the POM captures.</p>
<p><img height="340" width="500" src="http://www.javaworld.com/javaworld/jw-05-2006/images/jw-0529-maven1.gif" alt="" />&#160;</p>
<p><span id="more-195"></span></p>
<ol>
<li><strong>Identifier </strong>(artifactId-version.[packaging])
<ul>
<li>groupId &#8211; directory structure layout</li>
<li>artifactId</li>
<li>version</li>
<li>packaging type</li>
</ul>
</li>
<li><strong>Project relationship</strong> (Inheritance vs aggregation)
<ul>
<li><strong>Inheritance &#8211; </strong>If you have several Maven projects, and they all have similar configurations, you can <strong>refactor </strong>your projects by pulling out those similar configurations and making a parent project. Thus, all you have to do is to let your Maven projects inherit that <strong>parent </strong>project, and those configurations would then be applied to all of them. (Goal: simplify the pom). <em><strong>Syntax</strong>: Parent POM has &lt;packaging&gt;pom&lt;/packaging&gt; and Children POM specify &lt;parent&gt; element.</em> <em>However, parent has no knowledge of its children.</em></li>
<li><strong>aggregation </strong>- if you have a group of projects that are built or processed together, you can create a aggregator project and have that declares <strong>modules</strong> and sets <strong>packaging </strong>type to <strong>pom</strong>. By doing so, you&#8217;d only have to build the aggregator and the rest will follow. (Goal: simplify the build). <em><strong>Syntax</strong>: Aggregator POM has &lt;packaging&gt;pom&lt;/packaging&gt; and &lt;module&gt;xyz&lt;/module&gt; specified. However, module has no knowledge of the aggregator.<br />
        </em></li>
<li>You can use inheritance together with aggregation.</li>
</ul>
</li>
<li><strong>Choose packaging type</strong>
<ul>
<li>Defines what <strong>goals </strong>your project will be executed during the build process and what <strong>artifact type</strong> of your output.</li>
<li><strong>pom </strong>(package &gt; install &gt; deploy) and package is using site:attach-descriptor goal.</li>
<li><strong>jar </strong>and <strong>war </strong>(see Lifecycle below)</li>
</ul>
</li>
<li><strong>Path management</strong>
<ul>
<li>All directories not beginning with &#8220;/&#8221; or some other absolute path delimiter are                         relative to <em><code>${baseDir}</code></em>—the directory where the POM lives.</li>
</ul>
</li>
<li><strong>Lifecycle </strong>is composed of build <strong>phases </strong>and a phase is made up of 0 to many <strong>goals </strong>(ie tasks).&#160; A goal not bound to any build phase could be executed outside of the build lifecycle by direct invocation. There are three built-in build lifecycles: <strong>default</strong>, <strong>clean </strong>and <strong>site</strong>. These build phases below (plus the other build phases not shown here) are executed sequentially to complete the default lifecycle.
<ul>
<li><tt>validate</tt> &#8211; validate the project is correct and all necessary information is available</li>
<li><tt>process-resource</tt></li>
<li><tt>compile</tt> &#8211; compile the source code of the project</li>
<li><tt>process-test-resource</tt></li>
<li><tt>test-compile</tt></li>
<li><tt>test</tt> &#8211; test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed</li>
<li><tt>package</tt> &#8211; take the compiled code and package it in its distributable format, such as a JAR.</li>
<li><tt>integration-test</tt> &#8211; process and deploy the package if necessary into an environment where integration tests can be run</li>
<li><tt>verify</tt> &#8211; run any checks to verify the package is valid and meets quality criteria</li>
<li><tt>install</tt> &#8211; install the package into the local repository, for use as a dependency in other projects locally</li>
<li><tt>deploy</tt> &#8211; done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.</li>
<li><em>If you want the full lifecycle reference, check <a href="http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference">this </a>out.</em></li>
<li>
<p><img height="297" width="414" src="http://www.javaworld.com/javaworld/jw-12-2005/images/jw-1205-maven2.gif" alt="" /></p>
</li>
</ul>
</li>
<li><strong>Maven extension points</strong>
<ul>
<li><strong>plugins (contains 1 or more goals) </strong>can be used to plugin <strong>goal </strong>to the phase. And plugins can be seen as libraries to the build like dependencies to your projects. Note that adding the plugin on its own is not enough information &#8211; you must also specify the goals you want to run as part of your build. The goals that are configured will be added to the goals already bound to the lifecycle from the packaging selected. If more than one goal is bound to a particular phase, the order used is that those from the packaging are executed first, followed by those configured in the POM. Note that you can use the <tt>&lt;executions&gt;</tt> element to gain more control over the order of particular goals. (For details, see Customize Your Build Process below)</li>
</ul>
</li>
<li><strong>Dependencies Management</strong>
<ul>
<li><strong>Transitive dependency</strong> &#8211; You just tell Maven which libraries <em>you</em> need, and Maven will take care of the libraries that your libraries need (and so on).</li>
<li><strong>Dependency scope</strong>: <strong>compile </strong>(default), <strong>provided </strong>(use it compile but will not be deployed), <strong>runtime </strong>(not needed in compilation but execution like JDBC driver), <strong>test </strong>(only need for test compilation and run tests)</li>
<li>Create your own repository</li>
<li>Concept of <strong>Snapshot </strong>- depends on snapshot means depends on the latest version of the dependency as it gets download every time you run the build process.</li>
</ul>
</li>
<li><strong>Create your own archetype </strong></li>
<li><strong>Configuration Management</strong>
<ul>
<li>Configure the configuration via setting properties as variable that can be referenced via ${name} throughout your pom. There are many other ways to set properties—through the (1) command line, through the Maven (2) settings.xml files, through (3) filters. For example, if your box is behind a firewall, you may nee to go through a proxy to download the dependencies. To set this up, you can do it in settings.xml &lt;proxies&gt; element.</li>
<li>There is a <a href="http://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Super_POM">super pom</a> that all your projects are inherited from. So, you can taste the power of <strong>configuration via convention.</strong>&#160;</li>
</ul>
</li>
</ol>
<h2>Customize Your Build Process</h2>
<p><strong>Associate goals to the standard lifecycle</strong><small><br />
</small></p>
<blockquote>
<p>&lt;build&gt;<br />
&#160;&#160; &lt;pluginManagement&gt;<br />
&#160;&#160;&#160;&#160; &lt;plugins&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;plugin&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;groupId&gt;com.mycompany.example&lt;/groupId&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;artifactId&gt;maven-touch-plugin&lt;/artifactId&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160; &lt;version&gt;1.0&lt;/version&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;executions&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;execution&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;phase&gt;process-test-resources&lt;/phase&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;goals&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;goal&gt;timestamp&lt;/goal&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/goals&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/execution&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/executions&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/plugin&gt;<br />
&#160;&#160;&#160;&#160;&#160; &lt;/plugins&gt;<br />
&#160; &lt;/pluginManagement&gt;<br />
&lt;/build&gt;</p>
</blockquote>
<p>The above setting tells maven that you have a goal &#8220;timestamp&#8221; under maven-touch-plugin that you want to associate it to &#8220;process-test-resources&#8221; phase during the build process. You do this goal-phase association under &lt;execution&gt; element. You put this setting under &lt;pluginManagment&gt; because you want this to be inherited to all the children POMs. Otherwise, you can have &lt;plugins&gt; without &lt;pluginManagement&gt; and the setting will only apply to single POM.</p>
<p><strong>Just simply associate an plugin to the project</strong></p>
<blockquote>
<p>&#160;&#160;&#160;&#160; &lt;build&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160; &lt;finalName&gt;maven2example_webapp&lt;/finalName&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;plugins&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;plugin&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;groupId&gt;org.mortbay.jetty&lt;/groupId&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;artifactId&gt;maven-jetty-plugin&lt;/artifactId&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/plugin&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/plugins&gt;<br />
&#160;&#160;&#160;&#160; &lt;/build&gt;</p>
</blockquote>
<p>OK. This allow you to run your project in jetty web container. You notice that simply adding a few lines to a <em>pom.xml</em> file will automatically download and launch <a href="http://mortbay.org/">Jetty</a> (a lightweight servlet/JSP container), seamlessly installing and running the WAR file by issuing a command as below.<code><b><br />
</b></code></p>
<blockquote>
<p>&#160;&#160;&#160; C:\[project path]&gt;mvn jetty:run</p>
</blockquote>
<p><strong>You can also configure your plugin</strong></p>
<p>For example, if&#160; you wish to force compilation on Java 5, simply pass in the following option under the build <strong>configuration </strong>in the <i>pom.xml</i> file. The maven-compiler-plugin has already been used behind the scene. Here you just need to configure it. So, you don&#8217;t need to put other information here. Each <a href="http://maven.apache.org/plugins/index.html">plugin listed on the Maven 2 site</a> includes documentation on the various configuration options available.<code> <br />
</code></p>
<blockquote>
<p>&#160;&#160;&#160;&#160;&#160; &lt;build&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;plugins&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;plugin&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;configuration&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;source&gt;1.5&lt;/source&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;target&gt;1.5&lt;/target&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/configuration&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/plugin&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/plugins&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160; &lt;/build&gt;</p>
</blockquote>
<p><strong>If you want to extend maven via ant tasks, you can do that via plugin as well</strong></p>
<blockquote>
<p>&#160; &lt;build&gt;<br />
&#160;&#160;&#160; &#8230;<br />
&#160;&#160;&#160; &lt;plugins&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160; &lt;plugin&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;executions&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;execution&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;phase&gt;generate-sources&lt;/phase&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;goals&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;goal&gt;run&lt;/goal&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/goals&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong>&lt;configuration&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;tasks&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!&#8211; Ant tasks go here &#8211;&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/tasks&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/configuration&gt;</strong><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/execution&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/executions&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/plugin&gt;<br />
&#160;&#160;&#160;&#160; &lt;/plugins&gt;&#160;&#160;&#160; <br />
&#160; &lt;/build&gt;</p>
</blockquote>
<h2><strong>Useful commands</strong></h2>
<p><strong>To list out what goals a plugin contains:</strong></p>
<blockquote>
<p>mvn help:describe -Dplugin=org.apache.maven.plugins:maven-archetype-plugin -Dfull=true</p>
</blockquote>
<p><strong>To run archetype creation from the template installed locally:</strong> (You can delete local templates via removing the file in your user home directory)</p>
<blockquote>
<p>mvn archetype:generate -DartifactId=jp -DarchetypeCatalog=local</p>
</blockquote>
<h2>Reference</h2>
<p>This references below helps me to write this article:</p>
<ol>
<li><a href="http://www.javaworld.com/javaworld/jw-12-2005/jw-1205-maven.html?page=3">Introduction to Maven 2 &#8211; javaworld</a></li>
<li><a href="http://today.java.net/pub/a/today/2007/03/01/building-web-applications-with-maven-2.html">Building Web Application Using Maven 2 &#8211; java.net</a></li>
<li><a href="http://www.javaworld.com/javaworld/jw-05-2006/jw-0529-maven.html?page=6">Maven 2 POM demystified (build section) &#8211; javaworld</a></li>
</ol>
<p>&#160;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/implement-your-idea/build-your-website/build-your-project-via-maven-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
