<?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>Curious &#187; Build</title>
	<atom:link href="http://blogs.plexibus.com/category/build/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.plexibus.com</link>
	<description>It&#039;s easy if you know how</description>
	<lastBuildDate>Tue, 22 Jun 2010 14:45:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Eucalyptus: Euca2ools</title>
		<link>http://blogs.plexibus.com/2010/06/17/eucalyptus-euca2ools/</link>
		<comments>http://blogs.plexibus.com/2010/06/17/eucalyptus-euca2ools/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 15:44:53 +0000</pubDate>
		<dc:creator>roshanallan</dc:creator>
				<category><![CDATA[Appistry]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[cloudiq]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[Amazon EC2]]></category>
		<category><![CDATA[appistry cloudiq]]></category>
		<category><![CDATA[euca2ools]]></category>
		<category><![CDATA[eucalyptus]]></category>
		<category><![CDATA[eucalyptus install]]></category>
		<category><![CDATA[eucalyptus setup]]></category>
		<category><![CDATA[plexibus]]></category>
		<category><![CDATA[private]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blogs.plexibus.com/2010/06/17/eucalyptus-euca2ools/</guid>
		<description><![CDATA[In this series of posts on &#8220;Building an on-premise private cloud&#8221; we have so far:

Installed Eucalyptus, an Infrastructure-as-a-Service offering, and
Configured Eucalyptus to start VMs with IP addresses from a private VLAN

Before we jump into bundling, uploading, and registering images, let&#8217;s first download and install Euca2ools.


Euca2ools


Euca2ools are command-line utilities to help:

Manage Images (bundle, upload, register, delete, [...]]]></description>
			<content:encoded><![CDATA[<p>In this series of posts on &#8220;Building an on-premise private cloud&#8221; we have so far:</p>
<ul>
<li><a href="http://blogs.plexibus.com/2010/05/19/eucalyptus-setting-up-a-private-infrastructure-cloud/" target="_blank">Installed Eucalyptus</a>, an <i>Infrastructure-as-a-Service</i> offering, and</li>
<li><a href="http://blogs.plexibus.com/2010/05/26/eucalyptus-configuring-your-private-cloud-to-resemble-amazon-ec2/" target="_blank">Configured Eucalyptus</a> to start VMs with IP addresses from a private VLAN</li>
</ul>
<p>Before we jump into bundling, uploading, and registering images, let&#8217;s first download and install <a href="http://open.eucalyptus.com/wiki/Euca2oolsGuide_v1.1" target="_blank">Euca2ools</a>.</p>
<p>
<br/><br />
<strong><a name="intro">Euca2ools</a></strong>
</p>
<p>
Euca2ools are command-line utilities to help:</p>
<ul>
<li>Manage Images (bundle, upload, register, delete, etc.)</li>
<li>Manage Instances (start, reboot, terminate, list, etc.)</li>
<li>Manage Volumes &amp; Snapshots (attach, detach, list, create, delete, etc.)</li>
<li>Manage IP addresses (associate, disassociate, list, etc.)</li>
<li>Manage SSH key pairs (add, delete, list)</li>
<li>Manage Security groups (add, delete, list, add rules)</li>
<li>Query availability zones (clusters)</li>
</ul>
<p>Euca2ools is compatible with Amazon EC2 and S3 web services. In fact, Euca2ools is modeled after Amazon <a href="https://developer.amazonwebservices.com/connect/entry.jspa?externalID=351" target="_blank">EC2 API</a> and <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=368" target="_blank">EC2 AMI</a> tools.
</p>
<p>
<br/><br />
<strong><a name="install">Download &amp; Install</a></strong>
</p>
<p>
Since I have been using CentOS 5 32-bit, I&#8217;ll describe the tar ball install process for CentOS 5. Also, in my case I&#8217;ll install euca2ools on my <a href="http://blogs.plexibus.com/2010/05/19/eucalyptus-setting-up-a-private-infrastructure-cloud/" target="_blank">front-end machine</a> (192.168.0.114)</p>
<p><i>Note:</i> You may choose to go the <font face="Courier New">yum</font> (you will need to add the <font face="Courier New">http://www.eucalyptussoftware.com/downloads/repo/euca2ools/$VERSION/yum/centos/</font> repo first) route instead of the tar ball. </p>
<p><i>Note:</i> If you are using a Debian-based distro, feel free to install using apt-get (<font face="Courier New">apt-get install euca2ools</font>)</p>
<p>First download the tar.gz package for CentOS 5 32-bit &#8211; in this case, <font face="Courier New">euca2ools-1.2-centos-i386.tar.gz</font></p>
<p>Next un-tar the above package</p>
<pre class="java-codeface">
tar zxvf euca2ools-1.2-centos-i386.tar.gz
</pre>
<p>Before you install the rpm packages in the <font face="Courier New">euca2ools-1.2-centos-i386</font> directory, you need to install <font face="Courier New">swig</font> as follows:</p>
<pre class="java-codeface">
yum update
yum install swig
</pre>
<p>Next, go into <font face="Courier New">euca2ools-1.2-centos-i386</font> directory and install the rpm packages as follows:</p>
<pre class="java-codeface">
cd euca2ools-1.2-centos-i386
rpm -Uvh python25-2.5.1-bashton1.i386.rpm python25-libs-2.5.1-bashton1.i386.rpm euca2ools-1.2-1.i386.rpm
</pre>
<p>Confirm that euca2ools is install as follows:</p>
<pre class="java-codeface">
rpm -qa euca2ools
</pre>
<div style="width: 90%; border: 1px solid black; background-color: rgb(0, 0, 0); font-size: 11px; color: rgb(255, 255, 255);">
euca2ools-1.2-1
</div>
</p>
<p>
<br/><br />
<strong><a name="test">Testing Euca2ools</a></strong>
</p>
<p>
In the <a href="http://blogs.plexibus.com/2010/05/19/eucalyptus-setting-up-a-private-infrastructure-cloud/#test" target="_blank">first post</a> I used Amazon EC2 API tools to test the Eucalyptus install. To be precise I had used the <font face="Courier New">ec2-describe-availability-zones</font> command.</p>
<p>Now that we have Euca2ools installed we can use the <font face="Courier New">euca-describe-availability-zones</font> command instead. <i>Remember to <font face="Courier New">source</font> in the <font face="Courier New">eucarc</font> file first</i>.</p>
<pre class="java-codeface">
cd .euca
source eucarc
euca-describe-availability-zones verbose
</pre>
<div style="width: 90%; border: 1px solid black; background-color: rgb(0, 0, 0); font-size: 11px; color: rgb(255, 255, 255);">
AVAILABILITYZONE	rosh-cluster1	192.168.0.114<br />
AVAILABILITYZONE	|- vm types	free / max   cpu   ram  disk<br />
AVAILABILITYZONE	|- m1.small	0004 / 0004   1    128     2<br />
AVAILABILITYZONE	|- c1.medium	0004 / 0004   1    256     5<br />
AVAILABILITYZONE	|- m1.large	0002 / 0002   2    512    10<br />
AVAILABILITYZONE	|- m1.xlarge	0000 / 0000   2   1024    20<br />
AVAILABILITYZONE	|- c1.xlarge	0000 / 0000   4   2048    20
</div>
<p>Nice!
</p>
<p>
Feel free to play around with some of the other commands. You can get a list of commands by typing &#8220;euca&#8221; and pressing the <font face="Courier New">TAB</font> button twice. You could also run the command <font face="Courier New">ls /usr/bin | grep euca</font></p>
<div style="width: 90%; border: 1px solid black; background-color: rgb(0, 0, 0); font-size: 11px; color: rgb(255, 255, 255);">
euca-add-group<br />
euca_conf<br />
euca-delete-volume<br />
euca-describe-keypairs<br />
euca_killall<br />
euca-run-instances<br />
euca-add-keypair<br />
euca-confirm-product-instance<br />
euca-deregister<br />
euca-describe-regions<br />
eucalyptus-cloud<br />
euca_sync_key<br />
euca-allocate-address<br />
euca-create-snapshot<br />
euca-describe-addresses<br />
euca-describe-snapshots<br />
euca-modify-image-attribute<br />
euca-terminate-instances<br />
euca-associate-address<br />
euca-create-volume<br />
euca-describe-availability-zones<br />
euca-describe-volumes<br />
euca-reboot-instances<br />
euca-unbundle<br />
euca-attach-volume<br />
euca-delete-bundle<br />
euca-describe-groups<br />
euca-detach-volume<br />
euca-register<br />
euca-upload-bundle<br />
euca-authorize<br />
euca-delete-group<br />
euca-describe-image-attribute<br />
euca-disassociate-address<br />
euca-release-address<br />
euca-version<br />
euca-bundle-image<br />
euca-delete-keypair<br />
euca-describe-images<br />
euca-download-bundle<br />
euca-reset-image-attribute<br />
euca-bundle-vol<br />
euca-delete-snapshot<br />
euca-describe-instances<br />
euca-get-console-output<br />
euca-revoke
</div>
<p>To get more information on a particular command, type in the command name following by the argument <font face="Courier New">&#8211;help</font>. For instance:</p>
<pre class="java-codeface">
euca-describe-availability-zones --help
</pre>
<div style="width: 90%; border: 1px solid black; background-color: rgb(0, 0, 0); font-size: 11px; color: rgb(255, 255, 255);">
<p>Shows information about availability zones.</p>
<p>euca-describe-availability-zones [--region region] [-h, --help] [--version] [--debug] [zone1 zone2...zoneN]</p>
<p>OPTIONAL PARAMETERS</p>
<p>&#8211;region			region to describe availability zones for</p>
<p>zone1 zone2&#8230;zoneN		zones to describe. </p>
<p>-a, &#8211;access-key		User&#8217;s Access Key ID.</p>
<p>-s, &#8211;secret-key		User&#8217;s Secret Key.</p>
<p>-U, &#8211;url			URL of the Cloud to connect to.</p>
<p>&#8211;config			Read credentials and cloud settings from the<br />
				specified config file (defaults to $HOME/.eucarc or /etc/euca2ools/eucarc).</p>
<p>-h, &#8211;help			Display this help message.</p>
<p>&#8211;version 			Display the version of this tool.</p>
<p>&#8211;debug 			Turn on debugging.</p>
<p>Euca2ools will use the environment variables EC2_URL, EC2_ACCESS_KEY, EC2_SECRET_KEY, EC2_CERT, EC2_PRIVATE_KEY, S3_URL, EUCALYPTUS_CERT by default.
</p></div>
</p>
<p>
As we continue these series, we will see more and more of the <font face="Courier New">Euca2ools</font> commands.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.plexibus.com/2010/06/17/eucalyptus-euca2ools/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Appistry CloudIQ Maven plugin: Update fabric / far version</title>
		<link>http://blogs.plexibus.com/2010/05/11/appistry-cloudiq-maven-plugin-update-fabric-far-version/</link>
		<comments>http://blogs.plexibus.com/2010/05/11/appistry-cloudiq-maven-plugin-update-fabric-far-version/#comments</comments>
		<pubDate>Tue, 11 May 2010 16:24:16 +0000</pubDate>
		<dc:creator>roshanallan</dc:creator>
				<category><![CDATA[Appistry]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[cloudiq]]></category>
		<category><![CDATA[appistry cloud platform]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[maven-cloudiq-plugin]]></category>
		<category><![CDATA[production]]></category>
		<category><![CDATA[qa]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://blogs.plexibus.com/2010/05/11/appistry-cloudiq-maven-plugin-update-fabric-far-version/</guid>
		<description><![CDATA[Ever since Appistry CloudIQ Maven plugin has been open-sourced on Google code, enhancements and features are being added regularly. A recent feature that was added was the update fabric/far version goal.
Update fabric/far versionThe update fabric/far version goal of the Appistry CloudIQ Maven plugin automates the version update of the fabric/far artifact and integrates this process [...]]]></description>
			<content:encoded><![CDATA[<p>Ever since <a href="http://code.google.com/p/maven-cloudiq-plugin/" target="_blank">Appistry CloudIQ Maven plugin</a> has been <a href="http://blogs.plexibus.com/2010/04/20/appistry-cloudiq-maven-plugin-on-google-code/">open-sourced on Google code</a>, enhancements and features are being added regularly. A recent feature that was added was the <i><a href="http://code.google.com/p/maven-cloudiq-plugin/issues/detail?id=2&amp;can=1" target="_blank">update fabric/far version</a></i> goal.</p>
<p><strong>Update fabric/far version</strong><br />The update fabric/far version goal of the Appistry CloudIQ Maven plugin automates the version update of the fabric/far artifact and integrates this process into the Maven build life-cycle of the CloudIQ artifact.</p>
<div style="float: right; margin: 10px 0pt 10px 30px; padding: 10px 20px 20px; width: 33%; border: 1px solid black; background-color: rgb(244, 244, 244); font-size: 11px;"><strong>What is fabric/far versioning and why is it necessary?</strong>?
<p>The <font face="Courier New">version</font> attribute in the <a href="http://www.appistry.com/community/wiki/display/cloudiq43/Fabric+Application+Definition+XML" target="_blank">fabric</a> and <a href="http://www.appistry.com/community/wiki/display/cloudiq43/Fabric+Archive+%28FAR%29+Definition+XML" target="_blank">far</a> application descriptors enable CloudIQ platform to distinguish between older and newer versions of the application. </p>
<p>When a fabric/far file is deployed with a version higher than the existing, CloudIQ platform ensures that the new version of the fabric/far will replace the existing version on all nodes in the cloud. </p>
<p>So if you want to deploy your updated application to Appistry CloudIQ platform, increment the version in the fabric or far application descriptor, package the app and then deploy it.</p>
<p></div>
<p>During development or build/run/test cycle, the process of manually having to update the version of the fabric/far becomes painful real quick. And heaven forbid that your forget to update the version and attempt a deploy &#8211; Appistry CloudIQ rejects the artifact with a nasty message stating that the version that you are attempting to deploy is older than the version it has currently.</p>
<p>The <font face="Courier New">cloudiq:update-far-version</font> goal alleviates the above problem by automating the update of the <font face="Courier New">version</font> value.</p>
<p><strong>Usage</strong><br />To update the version of the fabric/far application, run this goal as:
<pre class="java-codeface">
mvn cloudiq:update-far-version
</pre>
<p>Assuming you have configured the Appistry CloudIQ Maven plugin as follows in your project pom:
<pre class="xml-codeface">
&lt;build&gt;
    &lt;plugins&gt;
        &lt;plugin&gt;
		&lt;groupId&gt;com.appistry.maven.plugins&lt;/groupId&gt;
		&lt;artifactId&gt;maven-cloudiq-plugin&lt;/artifactId&gt;
		&lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
		&lt;configuration&gt;
			&lt;appName&gt;CreditRules_App&lt;/appName&gt;
			&lt;appFilename&gt;CreditRules_App&lt;/appFilename&gt;
			&lt;remoteSshHost&gt;192.168.5.55&lt;/remoteSshHost&gt;
			&lt;remoteSshPort&gt;22&lt;/remoteSshPort&gt;
			&lt;remoteSshUsername&gt;fabricuser&lt;/remoteSshUsername&gt;
			&lt;remoteSshPassword&gt;fabricuser&lt;/remoteSshPassword&gt;
			&lt;!--
				&lt;farVersionUpdateSkip&gt;false&lt;/farVersionUpdateSkip&gt;
				&lt;farVersion&gt;99&lt;/farVersion&gt;
			--&gt;
		&lt;/configuration&gt;
	&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/build&gt;
</pre>
<p>the <font face="Courier New">mvn package cloudiq:update-far-version</font> command will update (increment by 1) the version value in the fabric/far application descriptor (in this case, <font face="Courier New">CreditRules_App.xml</font>). <i>Currently the only requirement is that the version defined in the application descriptor is an integer</i>. We will talk a little more about this requirement a little later.</p>
<p><strong><i>Note</i></strong>: This goal (<font face="Courier New">cloudiq:update-far-version</font>) is part of the <font face="Courier New">cloudiq:package</font> goal which essentially performs the following:
<ol>
<li>copies the resources/scripts files (<font face="Courier New">cloudiq:copy-resources</font> goal) to a work directory,</li>
<p>
<li>updates the version of the fabric/far application descriptor (<font face="Courier New">cloudiq:update-far-version</font> goal),</li>
<p>
<li>gathers the dependent (if any) jars (<font face="Courier New">cloudiq:assemble-dependencies</font> goal), and</li>
<p>
<li>runs fabric_pkg to create the actual fabric/far artifact.</li>
<p></ol>
<p><i>99.99%</i> of the time you will run the <font face="Courier New">cloudiq:package</font> goal which as described above will update the version and package the app as a deployable CloudIQ artifact.</p>
<p><strong>Configuration</strong><br />The <font face="Courier New">cloudiq:update-far-version</font> goal does not need any configuration since all it does is read the existing version and increment it. But there are some configuration parameters around this goal that come in handy when needed.</p>
<p><font face="Courier New">farVersionUpdateSkip</font><br />Setting this parameter to true will skip the execution of the <font face="Courier New">cloudiq:update-far-version</font> goal. This comes in handy if you want to update the version by hand or using some other process. The default is <font face="Courier New">false</font> i.e. the version gets updated when either <font face="Courier New">cloudiq:package</font> goal or <font face="Courier New">cloudiq:update-far-version</font> goal is run.</p>
<p><font face="Courier New">farVersion</font><br />This parameter allows you to specify a version that will be used and hence overrides the default behavior of the <font face="Courier New">cloudiq:update-far-version</font> goal which is to increment the version by 1.<br />This parameter takes a <font face="Courier New">string</font> as it value. That&#8217;s right, a <b>String</b> rather than an integer. So you could set it to a value like &#8220;1.0&#8243; or &#8220;5.0.2&#8243;.<br />I generally use this parameter when I tag my build in my source control management (SCM) and then use the tag value as the <font face="Courier New">version</font>. Of course, the version (SCM tag) is higher than the version deployed (which generally is an older SCM tag). This helps in co-relating what the version deployed to the version tagged in SCM.</p>
<p><strong>Best Practices</strong><br />Recall, a little above I stated that one of the requirements is that the version defined in the application descriptor is an integer. But then in the <font face="Courier New">farVersion</font> property I contradicted it by saying that you could pass in a string. <br />Well, let&#8217;s clear this up. </p>
<p><i>Development environment/cloud</i><br />Generally during development, you are building from HEAD (or TRUNK or MAIN branch) of your SCM and deploying to a development cloud. And during development you frequently build, deploy and test your changes. During this time, you don&#8217;t really care what the <font face="Courier New">version</font> is of the fabric/far as long as it is greater than the existing one so you can deploy it without Appistry CloudIQ baulking at your deploy attempts. Therefore during this time the <i>&#8220;increment by 1&#8243;</i> strategy comes in handy. Hence it is a good practice to:
<ul>
<li>Set the initial version in the fabric/far application descriptor to an integer, say 1 </li>
<p>
<li>Do not specify a <font face="Courier New">farVersion</font> property</li>
<p></ul>
<p>and let the plugin do the job of updating the version every time you build.</p>
<p><i>Test or QA or Production environment/cloud</i><br />Once you are ready to deploy to a test/QA/production cloud, tag your code in SCM and use the tag as the value of the <font face="Courier New">farVersion</font> property. This way you know what version of code is deployed in your test/qa/production environments and you can reproduce those artifacts at will.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.plexibus.com/2010/05/11/appistry-cloudiq-maven-plugin-update-fabric-far-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Appistry CloudIQ Maven plugin: Birth and moving forward</title>
		<link>http://blogs.plexibus.com/2010/04/21/appistry-cloudiq-maven-plugin-birth-and-moving-forward/</link>
		<comments>http://blogs.plexibus.com/2010/04/21/appistry-cloudiq-maven-plugin-birth-and-moving-forward/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 21:24:03 +0000</pubDate>
		<dc:creator>roshanallan</dc:creator>
				<category><![CDATA[Appistry]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[cloudiq]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[google code]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[maven-cloudiq-plugin]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blogs.plexibus.com/2010/04/21/appistry-cloudiq-maven-plugin-birth-and-moving-forward/</guid>
		<description><![CDATA[I finally added some wiki pages around maven-cloudiq-plugin. And I will be continually adding to the wiki in the days to come. But I thought I would take a moment to give some background on the plugin and describe some of the goals.

Origins&#8230;
maven-cloudiq-plugin currently started off as a simple way to integrate the creation of [...]]]></description>
			<content:encoded><![CDATA[<p>I finally added some wiki pages around <a href="http://code.google.com/p/maven-cloudiq-plugin/" target="_blank">maven-cloudiq-plugin</a>. And I will be continually adding to the wiki in the days to come. But I thought I would take a moment to give some background on the plugin and describe some of the goals.</p>
<p>
<strong>Origins&#8230;</strong></p>
<p><i>maven-cloudiq-plugin</i> currently started off as a simple way to integrate the creation of <a href="http://www.appistry.com/products" target="_blank">CloudIQ</a> artifacts (fabric and far files) while building a Maven project on the Mac OS. As you may know, you create CloudIQ artifacts using <font face="Courier New"><a href="http://www.appistry.com/community/wiki/display/latest/fabric_pkg" target="_blank">fabric_pkg</a></font> tool.</p>
<p>But, currently, there is no <font face="Courier New">fabric_pkg</font> for the Mac OS X. Therefore to create a fabric or far file you end up having to do the following:<br />
</srong></p>
<ol>
<li>
SCP all your files &#8211; fabric/far resources, primary artifact (jar, war, etc.), dependent libraries, scripts, etc. &#8211; to a remote host that has Appistry CloudIQ installed
</li>
<li>
SSH to the above remote host and run <font face="Courier New">fabric_pkg</font> to create the fabric or far artifact
</li>
<li>
Deploy the fabric / far artifact to the cloud
</li>
</ol>
<p>Too <u>time-consuming</u> in my opinion! And you end up repeating these steps over and over again. <a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself" target="_blank">DRY principle</a>, anyone?</p>
<p>Heck if you are developing (on Windows or Linux) a Java application, installation package or service that get packaged as a Fabric or Far file and are using Maven as a build tool, to create the actual fabric or far file, you have to manually run <font face="Courier New">fabric_pkg</font>. Still a <i>pain</i>.</p>
<p>Since I use Maven a heck lot, I had to eliminate some of the repeated tasks. And thus the <a href="http://code.google.com/p/maven-cloudiq-plugin/" target="_blank">maven-cloudiq-plugin</a> came forth. The primary objective of which was to integrate and make easy the building of CloudIQ artifacts while building a Maven project.</p>
<p>
<strong>Looking forward&#8230;</strong></p>
<p>Enough with the origins. What can we expect moving forward?</p>
<p>Although I won&#8217;t go into every single enhancement or new feature here (I haven&#8217;t thought about everything; that&#8217;s where you could contribute), I will list out some of the pressing issues that would greatly improve the usability of the plugin.</p>
<p>Some enhancements and features:
</p>
<ol>
<li>
Auto-increment the fabric or far version in the application descriptors by looking up the latest version running in the cloud. Also, allow for manual override by user. <i>Currently, the user has to update the application descriptors manually.</i>
</li>
<li>
Auto-creation of <a href="http://www.appistry.com/community/wiki/display/latest/Fabric+Application+Definition+XML" target="_blank">Fabric</a> and <a href="http://www.appistry.com/community/wiki/display/latest/Fabric+Archive+%28FAR%29+Definition+XML" target="_blank">Far</a> application descriptors. <i>Currently, the user has to create these application descriptors by hand.</i>
</li>
<li>
Auto-discover the appropriate CloudIQ artifact (.fabric or .far) that needs to be generated. <i>Currently, the default is fabric. This is configurable though via the <font face="Courier New">appExtension</font> parameter.</i>
</li>
<li>
Ability to deploy CloudIQ artifacts (and files) to clouds.
</li>
<li>
Ability to specify the list of dependent jars required at fabric package time. <i>Currently, the entire kitchen sink of Maven dependencies get downloaded even though only a handful of jars gets included in the fabric file</i>
</li>
<li>
Capture <i>remote</i> <font face="Courier New">fabric_pkg</font> output &amp; error stream and log it out to the standard output during the Maven build.
</li>
</ol>
<p>So, above are some features/enhancements that need working on along with unit tests.</p>
<p>
<strong>Interested enough to contribute?</strong></p>
<p>If you are interested in contributing to the enhancements, features, and bug-fixes and making the maven-cloudiq-plugin robust and easy to use, feel free to <a href="http://code.google.com/p/maven-cloudiq-plugin/source/checkout" target="_blank">clone the repository</a>, send/attach code snippets, add additional enhancement/feature requests, etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.plexibus.com/2010/04/21/appistry-cloudiq-maven-plugin-birth-and-moving-forward/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Appistry CloudIQ Maven plugin on Google Code</title>
		<link>http://blogs.plexibus.com/2010/04/20/appistry-cloudiq-maven-plugin-on-google-code/</link>
		<comments>http://blogs.plexibus.com/2010/04/20/appistry-cloudiq-maven-plugin-on-google-code/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 21:49:09 +0000</pubDate>
		<dc:creator>roshanallan</dc:creator>
				<category><![CDATA[Appistry]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[cloudiq]]></category>
		<category><![CDATA[fabric package]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[maven-cloudiq-plugin]]></category>
		<category><![CDATA[maven2]]></category>

		<guid isPermaLink="false">http://blogs.plexibus.com/2010/04/20/appistry-cloudiq-maven-plugin-on-google-code/</guid>
		<description><![CDATA[I finally decided to bite the bullet and publish the work-in-progress maven-cloudiq-plugin code to Google code.

Google Code and Mercurial
While I did not spend a ton of time evaluating a public project hosting provider, some of key things I was looking for in a project hosting provider was:


Must provide DVCS (distributed version control system)
Must provider some [...]]]></description>
			<content:encoded><![CDATA[<p>I finally decided to bite the bullet and publish the <i>work-in-progress</i> maven-cloudiq-plugin code to <a href="http://code.google.com/p/maven-cloudiq-plugin/" target="_blank">Google code</a>.</p>
<p>
<strong>Google Code and Mercurial</strong><br />
While I did not spend a ton of time evaluating a public project hosting provider, some of key things I was looking for in a project hosting provider was:
</p>
<ul>
<li>Must provide DVCS (distributed version control system)</li>
<li>Must provider some type of issue tracking system</li>
</ul>
<p>Although <a href="http://github.com/" target="_blank">GitHub</a> and <a href="http://bitbucket.org/" target="_blank">BitBucket</a> seemed to fit the bill, I decided to go with <a href="http://code.google.com/p/maven-cloudiq-plugin/" target="_blank">Google  code</a> since it offers <a href="http://mercurial.selenic.com/" target="_blank">Mercurial DVCS</a> (and Subversion as well). Mercurial (<font face="Courier New">hg</font>), IMHO, is faster and easier to learn than other DVCS. <i>Again, this is purely my opinion</i>. </p>
<p>Eclipse IDE has a nice <a href="http://www.javaforge.com/project/HGE" target="_blank">plugin</a> for <font face="Courier New">hg</font>. And NetBeans comes with support for <font face="Courier New">hg</font> out of the box.</p>
<p>
<strong>How to contribute</strong><br />
If you are reading this post, I would encourage you to contribute to the development of maven-cloudiq-plugin. You can do so easily by cloning the project, fixing bugs, developing new features, requesting new features, and so on.
</p>
<p>
What is the purpose of the Appistry CloudIQ Maven plugin? See <a href="http://blogs.plexibus.com/2010/04/21/appistry-cloudiq-maven-plugin-birth-and-moving-forward/">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.plexibus.com/2010/04/20/appistry-cloudiq-maven-plugin-on-google-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting System Environment variables in Windows using Windows Scripting Host</title>
		<link>http://blogs.plexibus.com/2009/04/14/setting-system-environment-variables-in-windows-using-windows-scripting-host/</link>
		<comments>http://blogs.plexibus.com/2009/04/14/setting-system-environment-variables-in-windows-using-windows-scripting-host/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 20:15:24 +0000</pubDate>
		<dc:creator>roshanallan</dc:creator>
				<category><![CDATA[Build]]></category>
		<category><![CDATA[setting environment variables]]></category>
		<category><![CDATA[windows scripting]]></category>
		<category><![CDATA[windows scripting host]]></category>
		<category><![CDATA[wsh]]></category>

		<guid isPermaLink="false">http://blogs.plexibus.com/?p=106</guid>
		<description><![CDATA[There are various ways to do this. The approach discussed here uses Windows Scripting Host (WSH) and probably offers the least amount of resistance and the most bang for the buck.
All Windows OSes with the exception of Windows 95 (I think) come with WSH pre-installed. And if you need it for Windows 95, you could [...]]]></description>
			<content:encoded><![CDATA[<p>There are various ways to do this. The approach discussed here uses Windows Scripting Host (WSH) and probably offers the least amount of resistance and the most bang for the buck.</p>
<p>All Windows OSes with the exception of Windows 95 (<i>I think</i>) come with WSH pre-installed. And if you need it for Windows 95, you could download it from the Microsoft site.</p>
<p>To display the version of WSH installed on Windows, type <strong><i>cscript</i></strong> at the command prompt and then press ENTER. It should display an output like the following:</p>
<blockquote><p>
C:\Documents and Settings\xxxx>cscript<br />
Microsoft (R) Windows Script Host Version 5.7<br />
Copyright (C) Microsoft Corporation. All rights reserved.</p>
<p>Usage: CScript scriptname.extension [option...] [arguments...]</p>
<p>Options:<br />
 //B         Batch mode: Suppresses script errors and prompts from displaying<br />
 //D         Enable Active Debugging<br />
&#8230;<br />
&#8230;
</p></blockquote>
<p>To read more about WSH: <a href="http://www.microsoft.com/technet/scriptcenter/guide/sas_wsh_overview.mspx">http://www.microsoft.com/technet/scriptcenter/guide/sas_wsh_overview.mspx</a></p>
<p>Enough talk. Let&#8217;s see an example script that sets an environment variable (say, &#8221;environSet.vbs&#8221;):</p>
<pre class="vb-codeface">
'Set JAVA_HOME, JRE_HOME and update PATH
set shellObj = WScript.CreateObject("WScript.Shell")
set envObj = shellObj.Environment("System")
envObj("JAVA_HOME")="C:\tools\jdk\jdk1.6.0_10"
envObj("JRE_HOME")="C:\tools\jdk\jdk1.6.0_10\jre"
envObj("PATH")=envObj("PATH") &#038; ";%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin\client"
</pre>
<p>To run the above script, you can open a command shell, type <i>cscript environSet.vbs</i> (or just <i>environSet.vbs</i>) and press ENTER or just double-click the <i>environSet.vbs</i> file.</p>
<p>In the above example, the JAVA_HOME and JRE_HOME system environment variables are set to &#8220;c:\tools\jdk\jdk1.6.0_10&#8243; and &#8220;c:\tools\jdk\jdk1.6.0_10\jre&#8221; respectively. The PATH system environment variable is <u>updated</u> and appended with &#8220;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin\client&#8221;.</p>
<p><strong>Notes</strong>:</p>
<ul>
<li>If the variables do not exist, they are created. If they already exist, they will be over-written unless you take care to append them as shown in the above example (see PATH)</li>
<li>When you run the above script, the updates are also reflected in the registry. In the above case since we have set the System environment variables you could browse to <i>HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\</i> in <i>regedit</i> to see the system environment variables.</li>
<li>Some pre-defined system variables such as PATH may not be picked by Windows services and will require a Windows Reboot.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blogs.plexibus.com/2009/04/14/setting-system-environment-variables-in-windows-using-windows-scripting-host/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fabric/grid enable Spring beans with Appistry EAF</title>
		<link>http://blogs.plexibus.com/2008/06/21/code-example-using-spring-beans-with-appistry-eaf-38/</link>
		<comments>http://blogs.plexibus.com/2008/06/21/code-example-using-spring-beans-with-appistry-eaf-38/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 05:13:57 +0000</pubDate>
		<dc:creator>roshanallan</dc:creator>
				<category><![CDATA[Build]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[Appistry EAF]]></category>
		<category><![CDATA[AppistryEAF]]></category>
		<category><![CDATA[fabric]]></category>
		<category><![CDATA[grid computing]]></category>
		<category><![CDATA[maven2]]></category>
		<category><![CDATA[plexibus]]></category>
		<category><![CDATA[roshan]]></category>
		<category><![CDATA[sequeira]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[xtp]]></category>

		<guid isPermaLink="false">http://blogs.plexibus.com/2008/06/21/code-example-using-spring-beans-with-appistry-eaf-38/</guid>
		<description><![CDATA[The following is a guide to fabric-enabling (or grid-enabling) your existing Spring beans using Appistry EAF.  We will use Maven for build configuration.
Pre-requisites to running the code sample provided:

JDK 1.5+
Appistry EAF 3.8 Release

Maven 2.0.7+.

An IDE to write/edit code. I use Eclipse 3.3.2 and the code in the zip file has eclipse-related files. But you [...]]]></description>
			<content:encoded><![CDATA[<p><big><span style="font-family: verdana;"><small>The following is a guide to fabric-enabling (or grid-enabling) your existing Spring beans using <a href="http://www.appistry.com">Appistry</a> <a href="http://www.appistry.com/products/eaf/index.html">EAF</a>.  We will use Maven for build configuration.</small></span></big></p>
<p><big><span style="font-family: verdana;"><small>Pre-requisites to running the code sample provided:</small></span></big></p>
<ul>
<li><big><span style="font-family: verdana;"><a href="http://java.sun.com/javase/downloads/index.jsp" target="_blank"><small>JDK 1.5+</small></a></span></big></li>
<li><big><span style="font-family: verdana;"><small><a href="http://www.appistry.com/developers/content/downloads/download" target="_blank">Appistry EAF 3.8 Release<br />
</a></small></span></big></li>
<li><big><span style="font-family: verdana;"><small><a href="http://maven.apache.org/download.html" target="_blank">Maven 2.0.7+.<br />
</a></small></span></big></li>
<li><big><span style="font-family: verdana;"><small>An IDE to write/edit code. I use <a href="http://www.eclipse.org/downloads" target="_blank">Eclipse</a> 3.3.2 and the code in the zip file has eclipse-related files. But you could easily download the code and use it with an IDE of your choice.</small></span></big></li>
<li><big><span style="font-family: verdana;"><small><a href="http://m2eclipse.codehaus.org" target="_blank">m2eclipse plugin</a> &#8211; maven integration for Eclipse. <em>*This is optional*, but if you are using Eclipse as your IDE, I recommend using it.</em><br />
</small></span></big></li>
</ul>
<p><span style="font-family: sans-serif;"><strong>Installing the above software<br />
</strong>See <a href="http://www.appistry.com/developers/wiki/display/eaf38dev/Software+Development+Kit+CentOS%2C+RHEL%2C+and+SuSE+installation" target="_blank">here</a> on how to install Appistry EAF 3.8 Release on Cent OS, RHEL, and SuSE.<br />
See <a href="http://www.appistry.com/developers/wiki/display/eaf38dev/Software+Development+Kit+Windows+Installation" target="_blank">here</a> on how to install Appistry EAF 3.8 Release on Cent OS, RHEL, and SuSE.<br />
</span></p>
<p>Installation instructions for Java, Maven and Eclipse are provided on their respective web sites.</p>
<p><strong>Creating the Maven project</strong><br />
This example is based on the tutorial samples (spring_hello_world &#8211; see tutorial_samples.zip or tutorial_samples.tgz) provided on <a href="http://www.appistry.com/developers/wiki/display/eaf38dev/Hello+World+with+Spring+Beans" target="_blank">this</a> page.<br />
Allright, let&#8217;s get started by designing some components:</p>
<blockquote><p><em><span style="font-family: 'Courier New';">HelloWorldSpringService</span> &#8211; interface that exposes a single &#8220;greet&#8221; method. Remember &#8211; program to interfaces!</em></p>
<p><em><span style="font-family: 'Courier New';">HelloWorldSpringServiceBean</span> &#8211; provides the implementation for HelloWorldSpringService.</em></p>
<p><em><span style="font-family: 'Courier New';">HelloWorldSpringClient</span> &#8211; client that calls the HelloWorldSpringService.greet method<br />
</em></p></blockquote>
<p>Since <span style="font-family: 'Courier New';">HelloWorldSpringService</span> interface is implemented by <span style="font-family: 'Courier New';">HelloWorldSpringServiceBean</span> and is used by <span style="font-family: 'Courier New';">HelloWorldSpringClient</span>, let&#8217;s put <span style="font-family: 'Courier New';">HelloWorldSpringService</span><small><big> into a common module, say HelloWorldCommon.<br />
</big><span style="font-family: 'Courier New';"><br />
<big>HelloWorldSpringServiceBean</big></span><big> could go into a HelloWorldService module while <span style="font-family: 'Courier New';">HelloWorldSpringClient</span> could go into a HelloWorldClient module.</big></small><small><big>The above structure provides a clean separation between the interface, implementation(s), and the client.</big></small><small><big>Now that we have the structure laid out, let&#8217;s start by creating these maven modules. I&#8217;m not going to use the m2eclipse plugin to create a multi-module project in eclipse, but instead will use <a href="http://blogs.plexibus.com/2007/12/02/maven-guide-part-one/"><span style="font-family: 'Courier New';">mvn</span> from the command line</a> to create the modules. You are free to use the m2eclipse plugin to create the project and modules. <em>Usage of m2eclipse is beyond the scope of this article.</em></big></small><small><big>First, let&#8217;s create a project, HelloWorldSpring, that will be the parent of HelloWorldCommon, HelloWorldService, and HelloWorldClient. Open a shell, change to your eclipse workspace directory, type in the following command and hit enter:</big></small></p>
<blockquote><p><big><span style="font-family: 'Courier New';"><small>mvn archetype:create<br />
-DgroupId=com.appistry.samples<br />
-DartifactId=HelloWorldSpring</small></span><br />
</big></p></blockquote>
<p>The above command will create a HelloWorldSpring maven project.<br />
* Non m2eclipse plugin users: <em>If you do not plan on using m2eclipse, from the command line change directory to HelloWorldSpring directory, type the following command and hit enter:</em></p>
<blockquote><p><big><span style="font-family: 'Courier New';"><small>mvn eclipse:eclipse</small></span><br />
</big></p></blockquote>
<p>Since we want this to be the parent project, go ahead and delete the &#8220;src&#8221; directory under HelloWorldSpring. Next, edit the HelloWorldSpring&#8217;s <span style="font-family: 'Courier New';">pom.xml</span> &#8211; change the <span style="font-family: 'Courier New';">packaging</span> element&#8217;s value from <span style="font-family: 'Courier New';">jar</span> to <span style="font-family: 'Courier New';">pom</span>.</p>
<p>Next we need to create the HelloWorldCommon, HelloWorldService, and HelloWorldClient modules. Go back to your command line, and change directory to &lt;workspace&gt;/HelloWorldSpring. Type the following commands and hit enter:</p>
<blockquote><p><big><span style="font-family: 'Courier New';"><small>mvn archetype:create -DgroupId=com.appistry.samples -DartifactId=HelloWorldCommon</small></span><br />
<span style="font-family: 'Courier New';"><small>mvn archetype:create -DgroupId=com.appistry.samples -DartifactId=HelloWorldService</small></span><br />
<span style="font-family: 'Courier New';"><small>mvn archetype:create -DgroupId=com.appistry.samples -DartifactId=HelloWorldClient</small></span><br />
</big></p></blockquote>
<p>The above 3 commands create the HelloWorldCommon, HelloWorldService, and HelloWorldClient modules under &lt;workspace&gt;/HelloWorldSpring directory.<br />
* Non m2eclipse plugin users: <em>If you do not plan on using m2eclipse, from the command line change directory to HelloWorldSpring directory, type the following command and hit enter:</em></p>
<blockquote><p><big><span style="font-family: 'Courier New';"><small>mvn eclipse:eclipse</small></span><br />
</big></p></blockquote>
<p>Next, fire up Eclipse and select the workspace that you created the above maven project under. Now, create a new Project by clicking &#8220;File -&gt; New -&gt; Project&#8230;&#8221;. Select &#8220;General -&gt; Project&#8221; and hit &#8220;Next&#8221;. Type &#8220;HelloWorldSpring&#8221; for Project Name and click &#8220;Finish&#8221;.<br />
You should see, a HelloWorldSpring project with HelloWorldCommon, HelloWorldService, and HelloWorldClient under it.<br />
If you plan on using m2eclipse plugin, now would be a good time to right-click on the project and select &#8220;Maven -&gt; Enable Dependency Management&#8221; and then right-click again on the project and select &#8220;Maven -&gt; Enable Nested Modules&#8221;<big>.<br />
</big>* Non m2eclipse plugin users: <em>Right-click &#8220;java&#8221; (under HelloWorldSpring -&gt; HelloWorldCommon -&gt; src -&gt; main), select &#8220;Build Path -&gt; Use as Source Folder&#8221;. Do the same for &#8220;java&#8221; under </em><em>HelloWorldSpring -&gt; HelloWorldService -&gt; src -&gt; main</em> and <small><big><em>HelloWorldSpring -&gt; HelloWorldClient -&gt; src -&gt; main.</em></big></small><small><big><em>Now you have the HelloWorldSpring multi-module project configured under Eclipse! See Figure 1<br />
</em></big></small></p>
<p align="center"><small><img style="float: none; max-width: 800px" src="http://blogs.plexibus.com/wp-content/uploads/2008/06/appistryexamplemvnproject.png" alt="" /></small></p>
<p align="center"><small>Figure 1</small></p>
<p><small><br />
<big>Next we need to update the poms.</big><br />
<big><strong><br />
HelloWorldSpring pom.xml</strong></big></small><big><br />
</big></p>
<blockquote><p><span style="font-family: verdana;"><em>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;project xmlns=&#8221;http://maven.apache.org/POM/4.0.0&#8243; xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:schemaLocation=&#8221;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&#8221;&gt;<br />
&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;<br />
&lt;groupId&gt;com.appistry.samples&lt;/groupId&gt;<br />
&lt;artifactId&gt;HelloWorldSpring&lt;/artifactId&gt;<br />
&lt;packaging&gt;pom&lt;/packaging&gt;<br />
&lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;<br />
&lt;name&gt;HelloWorldSpring&lt;/name&gt;&lt;properties&gt;<br />
&lt;!&#8211; Default JDK Level &#8211;&gt;<br />
&lt;jdkLevel&gt;1.5&lt;/jdkLevel&gt;<br />
&lt;/properties&gt;</em></span><span style="font-family: verdana;"><em>&lt;modules&gt;<br />
&lt;module&gt;HelloWorldService&lt;/module&gt;<br />
&lt;module&gt;HelloWorldClient&lt;/module&gt;<br />
&lt;module&gt;HelloWorldCommon&lt;/module&gt;<br />
&lt;/modules&gt;</em></span><span style="font-family: verdana;"><em>&lt;dependencyManagement&gt;<br />
&lt;dependencies&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;${project.groupId}&lt;/groupId&gt;<br />
&lt;artifactId&gt;HelloWorldCommon&lt;/artifactId&gt;<br />
&lt;version&gt;${project.version}&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;/dependencies&gt;<br />
&lt;/dependencyManagement&gt;</em></span><span style="font-family: verdana;"><em>&lt;dependencies&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;junit&lt;/groupId&gt;<br />
&lt;artifactId&gt;junit&lt;/artifactId&gt;<br />
&lt;version&gt;4.4&lt;/version&gt;<br />
&lt;scope&gt;test&lt;/scope&gt;<br />
&lt;/dependency&gt;<br />
&lt;/dependencies&gt;</em></span><span style="font-family: verdana;"><em>&lt;build&gt;<br />
&lt;pluginManagement&gt;<br />
&lt;plugins&gt;<br />
&lt;plugin&gt;<br />
&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;<br />
&lt;!&#8211;&lt;version&gt;2.0.2&lt;/version&gt;&#8211;&gt;<br />
&lt;executions&gt;<br />
&lt;execution&gt;<br />
&lt;id&gt;compile&lt;/id&gt;<br />
&lt;phase&gt;compile&lt;/phase&gt;<br />
&lt;goals&gt;<br />
&lt;goal&gt;compile&lt;/goal&gt;<br />
&lt;/goals&gt;<br />
&lt;/execution&gt;<br />
&lt;execution&gt;<br />
&lt;id&gt;unit-test-compile&lt;/id&gt;<br />
&lt;goals&gt;<br />
&lt;goal&gt;testCompile&lt;/goal&gt;<br />
&lt;/goals&gt;<br />
&lt;/execution&gt;<br />
&lt;/executions&gt;<br />
&lt;configuration&gt;<br />
&lt;source&gt;${jdkLevel}&lt;/source&gt;<br />
&lt;target&gt;${jdkLevel}&lt;/target&gt;<br />
&lt;/configuration&gt;<br />
&lt;/plugin&gt;</em></span><span style="font-family: verdana;"><em>&lt;plugin&gt;<br />
&lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;<br />
&lt;version&gt;2.4.2&lt;/version&gt;<br />
&lt;configuration&gt;<br />
&lt;excludes&gt;<br />
&lt;exclude&gt;**/*$*&lt;/exclude&gt;<br />
&lt;/excludes&gt;<br />
&lt;/configuration&gt;<br />
&lt;/plugin&gt;</em></span><span style="font-family: verdana;"><em>&lt;plugin&gt;<br />
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br />
&lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;<br />
&lt;version&gt;1.1&lt;/version&gt;<br />
&lt;/plugin&gt;</em></span></p>
<p><span style="font-family: verdana;"><em>&lt;plugin&gt;<br />
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br />
&lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;<br />
&lt;version&gt;2.0&lt;/version&gt;<br />
&lt;/plugin&gt;<br />
&lt;/plugins&gt;<br />
&lt;/pluginManagement&gt;<br />
&lt;/build&gt;</em></span></p>
<p><span style="font-family: verdana;"><em>&lt;/project&gt;</em></span></p></blockquote>
<p><strong>HelloWorldService pom.xml</strong><br />
Add HelloWorldCommon dependency to HelloWorldService</p>
<blockquote><p><em>&lt;?xml version=&#8221;1.0&#8243;?&gt;<br />
&lt;project&gt;<br />
&lt;parent&gt;<br />
&lt;artifactId&gt;HelloWorldSpring&lt;/artifactId&gt;<br />
&lt;groupId&gt;com.appistry.samples&lt;/groupId&gt;<br />
&lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;<br />
&lt;/parent&gt; </em><em>&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;<br />
&lt;artifactId&gt;HelloWorldService&lt;/artifactId&gt;<br />
&lt;name&gt;HelloWorldService&lt;/name&gt;</em><em>&lt;dependencies&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;${project.groupId}&lt;/groupId&gt;<br />
&lt;artifactId&gt;HelloWorldCommon&lt;/artifactId&gt;<br />
&lt;version&gt;${project.version}&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;/dependencies&gt;<br />
&lt;/project&gt;</em></p></blockquote>
<p><strong>HelloWorldClient pom.xml<br />
</strong>Add HelloWorldCommon dependency to HelloWorldClient. You will also need to add Spring as a dependency. I&#8217;m using Spring 2.5.4.<big><br />
</big></p>
<blockquote><p><em>&lt;?xml version=&#8221;1.0&#8243;?&gt;<br />
&lt;project&gt;<br />
&lt;parent&gt;<br />
&lt;artifactId&gt;HelloWorldSpring&lt;/artifactId&gt;<br />
&lt;groupId&gt;com.appistry.samples&lt;/groupId&gt;<br />
&lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;<br />
&lt;/parent&gt;&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;<br />
&lt;artifactId&gt;HelloWorldClient&lt;/artifactId&gt;<br />
&lt;name&gt;HelloWorldClient&lt;/name&gt;</em><em>&lt;dependencies&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;${project.groupId}&lt;/groupId&gt;<br />
&lt;artifactId&gt;HelloWorldCommon&lt;/artifactId&gt;<br />
&lt;version&gt;${project.version}&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.springframework&lt;/groupId&gt;<br />
&lt;artifactId&gt;spring&lt;/artifactId&gt;<br />
&lt;version&gt;2.5.4&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;commons-logging&lt;/groupId&gt;<br />
&lt;artifactId&gt;commons-logging&lt;/artifactId&gt;<br />
&lt;version&gt;1.1.1&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;/dependencies&gt;<br />
&lt;/project&gt;</em></p></blockquote>
<p><big><br />
<span style="font-family: 'Courier New';"><small></small></span></big></p>
<p><big><span style="font-family: 'Courier New';"><small></small></span></big>Now we are ready to code the <span style="font-family: 'Courier New';">HelloWorldSpringService</span>, <span style="font-family: 'Courier New';">HelloWorldSpringServiceBean</span>, and <span style="font-family: 'Courier New';">HelloWorldSpringClient</span>.</p>
<p><strong>HelloWorldSpringService</strong><br />
The <span style="font-family: 'Courier New';">HelloWorldSpringService</span> has one method <span style="font-family: 'Courier New';">greet</span> which takes a <span style="font-family: 'Courier New';">String</span> parameter<span style="font-family: 'Courier New';">.<br />
</span></p>
<pre class="java-codeface">package com.appistry.samples.spring.helloworld;

public interface HelloWorldSpringService {
    String greet(String name);
}</pre>
<p>This interface goes under the HelloWorldCommon module under HelloWorldCommon/src/main/java.</p>
<p><strong>HelloWorldSpringServiceBean</strong><br />
The <span style="font-family: 'Courier New';">HelloWorldSpringServiceBean</span> class implements <span style="font-family: 'Courier New';">HelloWorldSpringService</span> interface. It goes under the HelloWorldService/src/main/java.</p>
<pre class="java-codeface">package com.appistry.samples.spring.helloworld.impl;

import com.appistry.samples.spring.helloworld.HelloWorldSpringService;

public class HelloWorldSpringServiceBean implements HelloWorldSpringService {

	public String greet(String name) {
		return "Hello World, " + name;
	}
}</pre>
<p><strong>HelloWorldSpringClient</strong><br />
Next, add the client that calls <span style="font-family: 'Courier New';">HelloWorldSpringService.greet</span>. <span style="font-family: 'Courier New';">HelloWorldSpringClient</span> class goes under HelloWorldClient/src/main/java.</p>
<pre class="java-codeface">package com.appistry.samples.spring.helloworld;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class HelloWorldSpringClient {

    public static void main(String[] args) {
	ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext("helloWorldClient-appContext.xml");

        HelloWorldSpringService localHWS = (HelloWorldSpringService) appContext.getBean("localHelloWorldBean");
System.out.println(localHWS.greet("locally."));

    }
}</pre>
<p><span style="font-family: 'Courier New';">helloWorldClient-appContext.xml</span> is detailed below and it goes under HelloWorldClient/src/main/resources (add the &#8220;resources&#8221; directory under HelloWorldClient/src/main as a &#8220;source&#8221; folder in Eclipse):</p>
<blockquote><p><span style="font-family: 'Courier New';"><em>&lt;?xml version=&#8221;1.0&#8243;?&gt;<br />
&lt;!DOCTYPE beans PUBLIC &#8220;-//SPRING//DTD BEAN//EN&#8221; &#8220;http://www.springframework.org/dtd/spring-beans.dtd&#8221;&gt;</em></span><span style="font-family: 'Courier New';"><em>&lt;beans&gt;<br />
&lt;bean id=&#8221;localHelloWorldBean&#8221; class=&#8221;com.appistry.samples.spring.helloworld.impl.HelloWorldSpringServiceBean&#8221;/&gt;<br />
&lt;/beans&gt;</em></span></p></blockquote>
<p><span style="font-family: 'Courier New';"><br />
</span>Let&#8217;s package, install and run HelloWorldSpring. From the command, type the following command from under &lt;workspace&gt;/HelloWorldSpring to package and install HelloWorldSpring artifacts to your local maven repository.</p>
<blockquote><p><big><span style="font-family: 'Courier New';"><small>mvn clean install</small></span><br />
</big></p></blockquote>
<p>From Eclipse, run <span style="font-family: 'Courier New';">HelloWorldSpringClient</span> as a Java Application. You should see an output like this:<big><br />
</big></p>
<blockquote><p><big><span style="font-family: arial;">&#8230;<br />
&#8230;<br />
<small>Jun 20, 2008 4:35:26 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons</small><br />
<small>INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@18a7efd: defining beans [localHelloWorldBean,fabricHelloWorldBean,fabric]; root of factory hierarchy</small><br />
<strong><small>Hello World, locally.</small></strong><br />
</span></big></p></blockquote>
<p>The HelloWorldSpringClient application loads the <span style="font-family: 'Courier New';">helloWorldClient-appContext.xml</span> spring application context, gets a reference to the HelloWorldSpringServiceBean and calls the greet method on it. So far we have seen nothing with regards to the fabric/grid. <big></big><big></big>If you would like to take a break, now would be a good time to do so. Go on. I&#8217;ll be right here.</p>
<p><strong>Exposing the HelloWorldSpringServiceBean as a fabric bean</strong><br />
To expose our existing HelloWorldSpringServiceBean in the fabric, we need to package and deploy the HelloWorldSpringServiceBean into the fabric.<br />
Let&#8217;s begin by first defining the HelloWorldSpringServiceBean in a spring application context (<span style="font-family: 'Courier New';">spring_hello_world_bean.xml</span>).</p>
<blockquote><p><span style="font-family: 'Courier New';"><em>&lt;?xml version=&#8221;1.0&#8243;?&gt;<br />
&lt;!DOCTYPE beans PUBLIC &#8220;-//SPRING//DTD BEAN//EN&#8221; &#8220;http://www.springframework.org/dtd/spring-beans.dtd&#8221;&gt;</em></span><span style="font-family: 'Courier New';"><em>&lt;beans&gt;<br />
&lt;bean id=&#8221;HelloWorldBean&#8221; class=&#8221;com.appistry.samples.spring.helloworld.impl.HelloWorldSpringServiceBean&#8221;/&gt;<br />
&lt;/beans&gt;</em></span></p></blockquote>
<p><small><big>Place this file under HelloWorldService/src/main/resources</big></small><br />
<small><big><strong>Note:</strong> Do we <em>need</em> to expose this in the fabric as a spring bean? No. We could have exposed it as a regular POJO. But the purpose of this example is to show Spring integration with Appistry EAF.</big></small><br />
<small><big>Now that we have wired the HelloWorldSpringServiceBean in a spring container, we need to define this bean as a Fabric Java Component. This is accomplished using the <a href="http://www.appistry.com/developers/wiki/display/eaf38dev/Component+Definition+XML" target="_blank">EAF Component Definition XML</a>.</big></small></p>
<p><strong>springHWSvc-component-defn.xml</strong></p>
<blockquote><p><span style="font-family: 'Courier New';"><em>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br />
&lt;java-components xmlns=&#8221;http://www.appistry.com/ns/component&#8221; xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:schemaLocation=&#8221;http://www.appistry.com/ns/component eaf-component.xsd&#8221;&gt;</em></span><span style="font-family: 'Courier New';"><em>&lt;component name=&#8221;mvnSpringHWSvcComponent&#8221; default-timeout=&#8221;5&#8243;&gt;<br />
&lt;spring-bean name=&#8221;HelloWorldBean&#8221;/&gt;<br />
&lt;/component&gt;<br />
&lt;/java-components&gt;</em></span></p></blockquote>
<p><big><br />
</big>where,<br />
the name attribute of the spring-bean element should<strong> match</strong> the bean id defined in the <span style="font-family: 'Courier New';">spring_hello_world_bean.xml</span> spring application context. In this case, HelloWorldBean.<br />
The default-timeout specifies how long to wait for a call (to a method) to return before timing out. In this case, we have specified 5 seconds.</p>
<p>Place this file under HelloWorldService/src/main/scripts for now.</p>
<p><small><big>So how does the EAF tie the component definition file and the spring application context? This is done via the <a href="http://www.appistry.com/developers/wiki/display/eaf38dev/Fabric+Application+Definition+XML" target="_blank">EAF Fabric Application Definition XML</a>.</big></small><small><big>The fabric application definition file describes the various files that comprise a EAF fabric application. This file is used by the <a href="http://www.appistry.com/developers/wiki/display/eaf38dev/fabric_pkg" target="_blank">Fabric Package</a> (which we will encounter momentarily) to bundle these files into &#8220;<em>.fabric</em>&#8221; package.</big></small></p>
<p><strong>springHWSvc-fabric-app-defn.xml</strong></p>
<blockquote><p><span style="font-family: 'Courier New';"><em>&lt;?xml version=&#8221;1.0&#8243;?&gt;<br />
&lt;!DOCTYPE app SYSTEM &#8220;FabricApp.dtd&#8221;&gt;&lt;app name=&#8221;mvnSpringHelloWorldSvc&#8221; version=&#8221;1.0.0&#8243;&gt;<br />
&lt;spring&gt;<br />
&lt;bean-factory-locator bean=&#8221;myBeanFactory&#8221; resource-location=&#8221;beanRefFactory.xml&#8221;/&gt;<br />
&lt;/spring&gt;</em></span><span style="font-family: 'Courier New';"><em>&lt;components&gt;<br />
&lt;file name=&#8221;springHWSvc-component-defn.xml&#8221;/&gt;<br />
&lt;/components&gt;</em></span><span style="font-family: 'Courier New';"><em>&lt;java-libs&gt;<br />
&lt;file name=&#8221;HelloWorldCommon.jar&#8221;/&gt;<br />
&lt;file name=&#8221;HelloWorldService.jar&#8221;/&gt;<br />
&lt;file name=&#8221;spring.jar&#8221;/&gt;<br />
&lt;file name=&#8221;commons-logging.jar&#8221;/&gt;<br />
&lt;/java-libs&gt;<br />
&lt;/app&gt;<big><br />
</big></em></span></p></blockquote>
<p>where,<br />
components, file &#8211; is component definition file that we defined earlier<br />
java-libs &#8211; dependant java libraries that will be included in the <span style="font-family: 'Courier New';">.fabric</span> application.</p>
<p>Place this file under HelloWorldService/src/main/scripts</p>
<p>The interesting element in this file is the . The bean-factory-locator element provides the Fabric with an implementation of Spring <span style="font-family: 'Courier New';">BeanFactory</span> to enable it to access spring bean containers / application contexts. The <span style="font-family: 'Courier New';">BeanFactory</span> (provided to the Fabric) is itself described in a spring application context. In this case, <span style="font-family: 'Courier New';">beanRefFactory.xml</span>.</p>
<p><strong>beanRefFactory.xml</strong><br />
<small><br />
</small></p>
<blockquote><p><span style="font-family: 'Courier New';"><big><small><em>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;!DOCTYPE beans PUBLIC &#8220;-//SPRING//DTD BEAN//EN&#8221; &#8220;http://www.springframework.org/dtd/spring-beans.dtd&#8221;&gt;&lt;beans&gt;<br />
&lt;bean id=&#8221;myBeanFactory&#8221; class=&#8221;org.springframework.context.support.ClassPathXmlApplicationContext&#8221;&gt;<br />
&lt;constructor-arg value=&#8221;spring_hello_world_bean.xml&#8221;/&gt;<br />
&lt;/bean&gt;<br />
&lt;/beans&gt;</em></small></big></span></p></blockquote>
<p>The bean id in <span style="font-family: 'Courier New';">beanRefFactory.xml</span> should match the &#8220;bean&#8221; attribute of bean-factory-locator in the fabric application definition xml. In this case, myBeanFactory.<br />
In the above application context, we have configured the ClassPathXmlApplicationContext (a super set of the BeanFactory) and pass it the name of the application context, <span style="font-family: 'Courier New';">spring_hello_world_bean.xml</span>, that contains our HelloWorldSpringServiceBean.</p>
<p>Place the <span style="font-family: 'Courier New';">beanRefFactory.xml</span> under HelloWorldService/src/main/resources</p>
<p>Now we are ready to package our HelloWorldSpringServiceBean, so we can deploy it on the fabric. As you can see we have not modified the java code at all. All we have done so far is configure the HelloWorldSpringServiceBean POJO in a spring application context, describe the bean as a fabric Java component, and tie these elements (along with the BeanFactory) together using a fabric definition file. <em>Non-intrusive, eh?</em></p>
<p><strong>Build and Package HelloWorldSpringServiceBean</strong><br />
Packaging the application into <span style="font-family: 'Courier New';">.fabric</span> file can be accomplished using the <a href="http://www.appistry.com/developers/wiki/display/eaf38dev/fabric_pkg" target="_blank">fabric pkg</a> command. The fabric package command takes a fabric application definition file as input and bundles the application files into a single package (<span style="font-family: 'Courier New';">.fabric</span>). We can configure the fabric package in the HelloWorldService pom.xml. But before we do this, we need to first download the dependant jars listed in the java-libs section of the fabric application definition xml (<small><big><span style="font-family: 'Courier New';">springHWSvc-fabric-app-defn.xml</span>) to a particular directory. This can be defined in the HelloWorldService pom.xml as well. Add the following snippet (after the <span style="font-family: 'Courier New';">dependencies</span> element and before the closing <span style="font-family: 'Courier New';">project</span> tag) to the HelloWorldService <span style="font-family: 'Courier New';">pom.xml</span>:</big></small><small> </small></p>
<blockquote><p><span style="font-family: 'Courier New';"><big><small><em>&lt;build&gt;<br />
&lt;plugins&gt;<br />
&lt;plugin&gt;<br />
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br />
&lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;<br />
&lt;version&gt;2.0&lt;/version&gt;<br />
&lt;executions&gt;<br />
&lt;execution&gt;<br />
&lt;id&gt;copy-required-dependencies&lt;/id&gt;<br />
&lt;phase&gt;install&lt;/phase&gt;<br />
&lt;goals&gt;<br />
&lt;goal&gt;copy&lt;/goal&gt;<br />
&lt;/goals&gt;<br />
&lt;configuration&gt;<br />
&lt;stripVersion&gt;true&lt;/stripVersion&gt;<br />
&lt;artifactItems&gt;<br />
&lt;artifactItem&gt;<br />
&lt;groupId&gt;${project.groupId}&lt;/groupId&gt;<br />
&lt;artifactId&gt;HelloWorldCommon&lt;/artifactId&gt;<br />
&lt;version&gt;${project.version}&lt;/version&gt;<br />
&lt;/artifactItem&gt;<br />
&lt;artifactItem&gt;<br />
&lt;groupId&gt;${project.groupId}&lt;/groupId&gt;<br />
&lt;artifactId&gt;${project.artifactId}&lt;/artifactId&gt;<br />
&lt;version&gt;${project.version}&lt;/version&gt;<br />
&lt;/artifactItem&gt;<br />
&lt;artifactItem&gt;<br />
&lt;groupId&gt;org.springframework&lt;/groupId&gt;<br />
&lt;artifactId&gt;spring&lt;/artifactId&gt;<br />
&lt;version&gt;2.5.4&lt;/version&gt;<br />
&lt;/artifactItem&gt;<br />
&lt;artifactItem&gt;<br />
&lt;groupId&gt;commons-logging&lt;/groupId&gt;<br />
&lt;artifactId&gt;commons-logging&lt;/artifactId&gt;<br />
&lt;version&gt;1.1.1&lt;/version&gt;<br />
&lt;/artifactItem&gt;<br />
&lt;/artifactItems&gt;<br />
&lt;outputDirectory&gt;${project.build.directory}/fabric-package&lt;/outputDirectory&gt;<br />
&lt;/configuration&gt;<br />
&lt;/execution&gt;<br />
&lt;/executions&gt;<br />
&lt;/plugin&gt;<br />
&lt;/plugins&gt;<br />
&lt;/build&gt;</em></small></big><br />
</span></p></blockquote>
<p>This directs Maven (at <span style="font-family: 'Courier New';">install</span> phase) to copy the HelloWorldCommon, HelloWorldService, spring and commons-logging jar files (with the versions stripped) from the local maven repository to the <span style="font-family: 'Courier New';">fabric-package</span> directory under HelloWorldService/target directory. Since I&#8217;ve listed the jar files without version numbers in the element (in <span style="font-family: 'Courier New';">springHWSvc-fabric-app-defn.xml</span> file), I tell Maven to strip the version numbers from the jar files while it&#8217;s performing the copy.</p>
<p>Now that we have addressed the jar dependencies, we are ready to configure the <a href="http://www.appistry.com/developers/wiki/display/eaf38dev/fabric_pkg" target="_blank"><span style="font-family: 'Courier New';">fabric_pkg</span></a> command. Let&#8217;s configure the fabric package in ant build file target and call the ant build file from maven.<br />
<strong>Note:</strong> <em>You don&#8217;t have to necessarily configure the fabric_pkg in an ant build file. You could have configured it within the pom itself.</em></p>
<p>First let&#8217;s check out the ant build file.</p>
<p><strong>build.xml</strong> (goes under HelloWorldService/src/main/scripts) &#8211; just displaying the necessary snippets. The attached HelloWorldSpring-source.zip contains all the source code listed here.</p>
<blockquote><p><span style="font-family: 'Courier New';"><em>&lt;!&#8211; copy the fabric application defn xml and component defn xml to fabric-package directory &#8211;&gt;<br />
&lt;target name=&#8221;init&#8221;&gt;<br />
&lt;copy todir=&#8221;target/fabric-package&#8221;&gt;<br />
&lt;fileset dir=&#8221;src/main/scripts&#8221;&gt;<br />
&lt;include name=&#8221;**/*-defn.xml&#8221;/&gt;<br />
&lt;/fileset&gt;<br />
&lt;/copy&gt;<br />
&lt;/target&gt;</em></span><span style="font-family: 'Courier New';"><em>&lt;!&#8211; execute fabric-pkg command &#8211;&gt;<br />
&lt;target name=&#8221;fabric-package&#8221; depends=&#8221;init&#8221;&gt;<br />
&lt;exec executable=&#8221;fabric_pkg&#8221;&gt;<br />
&lt;arg line=&#8221;target/fabric-package/springHWSvc-fabric-app-defn.xml&#8221; /&gt;<br />
&lt;/exec&gt;<br />
&lt;/target&gt;</em></span></p></blockquote>
<p>Now we need to update the HelloWorldService pom.xml to call the above ant build file. Add the following snippet (after the previous plugin definition and before the closing <span style="font-family: 'Courier New';">plugins</span> tag) to the HelloWorldService <span style="font-family: 'Courier New';">pom.xml</span>.<span style="font-family: 'Courier New';"> </span></p>
<blockquote><p><span style="font-family: 'Courier New';"><em>&lt;plugin&gt;<br />
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br />
&lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;<br />
&lt;version&gt;1.1&lt;/version&gt;<br />
&lt;executions&gt;<br />
&lt;execution&gt;<br />
&lt;id&gt;fabric-package&lt;/id&gt;<br />
&lt;phase&gt;install&lt;/phase&gt;<br />
&lt;goals&gt;<br />
&lt;goal&gt;run&lt;/goal&gt;<br />
&lt;/goals&gt;<br />
&lt;/execution&gt;<br />
&lt;/executions&gt;<br />
&lt;configuration&gt;<br />
&lt;tasks&gt;<br />
&lt;ant antfile=&#8221;src/main/scripts/build.xml&#8221; target=&#8221;fabric-package&#8221; /&gt;<br />
&lt;/tasks&gt;<br />
&lt;/configuration&gt;<br />
&lt;/plugin&gt;</em><br />
</span></p></blockquote>
<p><big><span style="font-family: 'Courier New';"><br />
</span></big>Here we direct Maven (again, at install phase) to call the &#8220;fabric-package&#8221; target of <span style="font-family: 'Courier New';">build.xml</span>. The fabric-package target first copies the <span style="font-family: 'Courier New';">springHWSvc-fabric-app-defn.xml</span> and <span style="font-family: 'Courier New';">springHWSvc-component-defn.xml</span> files to the HelloWorldService/target/fabric-package directory and then calls the <span style="font-family: 'Courier New';"><a href="http://www.appistry.com/developers/wiki/display/eaf38dev/fabric_pkg" target="_blank">fabric_pkg</a></span> executable to bundle the application files into &#8220;<span style="font-family: 'Courier New';">mvnSpringHelloWorldSvc.fabric</span>&#8221; file. You will notice that the name of the fabric file is the same as the <span style="font-family: 'Courier New';">name</span> attribute of the <span style="font-family: 'Courier New';">app</span> element in <span style="font-family: 'Courier New';">springHWSvc-fabric-app-defn.xml</span>.</p>
<p>We are done with the package configuration. Now, open a command shell, change directory to /HelloWorldSpring, type the following command and hit enter:</p>
<blockquote><p><span style="font-family: 'Courier New';">mvn clean install</span><big><br />
</big></p></blockquote>
<p>The above command will compile the sources, the application jars, install the application jars to the local maven repository on your local machine, and then create the <span style="font-family: 'Courier New';">mvnSpringHelloWorldSvc.fabric</span><small><big> under the HelloWorldSpring/HelloWorldService directory.<br />
</big><br />
<big>Now you are ready to deploy the </big></small><span style="font-family: 'Courier New';">mvnSpringHelloWorldSvc.fabric</span><small><big> to the EAF fabric.<br />
</big><br />
</small><big><strong><small>Deploy HelloWorldSpringServiceBean</small></strong><br />
</big>Let&#8217;s use the instructions detailed on the Appistry EAF wiki page &#8211; <a href="http://www.appistry.com/developers/wiki/display/eaf38dev/Building%2C+Packaging%2C+and+Deploying+a+Fabric+Application" target="_blank">Building, Packaging, and Deploying a Fabric application</a>. The <a href="http://www.appistry.com/developers/wiki/display/eaf38dev/fabric_ctl" target="_blank">fabric_ctl</a> command can be used to deploy a fabric application.</p>
<p>To deploy the <span style="font-family: 'Courier New';">HelloWorldSpringServiceBean</span> bundled in the <span style="font-family: 'Courier New';">mvnSpringHelloWorldSvc.fabric</span>, type the following command (from under &lt;workspace&gt;/HelloWorldSpring/HelloWorldService) with the correct fabric adminstrative user, password, and fabric address. If you have stuck with the defaults, the command is:</p>
<blockquote><p><span style="font-family: 'Courier New';">fabric_ctl -d 239.255.0.1:30000 -u fabric-admin/fabric-admin deploy </span><big><span style="font-family: 'Courier New';"><small>mvnSpringHelloWorldSvc.fabric</small></span><br />
</big></p></blockquote>
<p>You can verify if the deployment is successful or not by following the instructions on <a href="http://www.appistry.com/developers/wiki/display/eaf38dev/Building%2C+Packaging%2C+and+Deploying+a+Fabric+Application" target="_blank">this</a> wiki page.</p>
<p>If the above command didn&#8217;t throw any errors, you have successfully deployed the <span style="font-family: 'Courier New';">HelloWorldSpringServiceBean</span>, <em>without any code changes</em>, to the fabric.</p>
<p>Now that we have <span style="font-family: 'Courier New';">HelloWorldSpringServiceBean</span> deployed to the fabric, how do we call the greet method on it from HelloWorldSpringClient?</p>
<p><strong>Call HelloWorldSpringServiceBean remotely</strong><br />
Calling <span style="font-family: 'Courier New';">HelloWorldSpringServiceBean</span> from <span style="font-family: 'Courier New';">HelloWorldSpringClient</span> is achieved by a simple configuration in <span style="font-family: 'Courier New';">helloWorldClient-appContext.xml</span>. And adding Appistry EAF provided fabric.jar as a dependency to the HelloWorldClient pom.xml</p>
<p>Since Appistry EAF fabric.jar is not available on a public maven repository as of yet, we need to install it to our local maven repository on our local machine. To do this, open a command shell, change directory to $FABRIC_HOME/classes, type the following command and hit enter:</p>
<blockquote><p><span style="font-family: 'Courier New';">mvn install:install-file -Dfile=fabric.jar -DgroupId=com.appistry -DartifactId=fabric -Dversion=3.8.0.15 -Dpackaging=jar</span><big><br />
</big></p></blockquote>
<p>The above command will install fabric.jar to your local maven repository.</p>
<p>Next we need to add fabric.jar as a dependency to HelloWorldClient&#8217;s <span style="font-family: 'Courier New';">pom.xml:</span></p>
<blockquote><p><span style="font-family: 'Courier New';"><em>&lt;dependency&gt;<br />
&lt;groupId&gt;com.appistry&lt;/groupId&gt;<br />
&lt;artifactId&gt;fabric&lt;/artifactId&gt;<br />
&lt;version&gt;3.8.0.15&lt;/version&gt;<br />
&lt;/dependency&gt;</em><br />
</span></p></blockquote>
<p>Now we are ready to configure <span style="font-family: 'Courier New';">helloWorldClient-appContext.xml.</span><big><br />
</big>Append the following bean definitions to <span style="font-family: 'Courier New';">helloWorldClient-appContext.xml</span> located under &lt;workspace&gt;/HelloWorldSpring/HelloWorldClient:<span style="font-family: 'Courier New';"> </span></p>
<blockquote><p><span style="font-family: 'Courier New';"><em>&lt;bean id=&#8221;fabricHelloWorldBean&#8221; class=&#8221;com.appistry.spring.FabricProxyFactoryBean&#8221;&gt;<br />
&lt;property name=&#8221;serviceInterface&#8221; value=&#8221;com.appistry.samples.spring.helloworld.HelloWorldSpringService&#8221;/&gt;<br />
&lt;property name=&#8221;fabric&#8221;&gt;<br />
&lt;ref local=&#8221;fabric&#8221;/&gt;<br />
&lt;/property&gt;<br />
&lt;property name=&#8221;applicationName&#8221; value=&#8221;mvnSpringHelloWorldSvc&#8221;/&gt;<br />
&lt;property name=&#8221;componentName&#8221; value=&#8221;mvnSpringHWSvcComponent&#8221;/&gt;<br />
&lt;/bean&gt;&lt;bean id=&#8221;fabric&#8221; class=&#8221;com.appistry.fabric.Fabric&#8221;&gt;<br />
&lt;constructor-arg value=&#8221;239.255.0.116&#8243;/&gt;<br />
&lt;constructor-arg value=&#8221;31000&#8243;/&gt;<br />
&lt;/bean&gt;<br />
</em></span></p></blockquote>
<p><big></big>The bean fabricHelloWorldBean defines a <span style="font-family: 'Courier New';">com.appistry.spring.FabricProxyFactoryBean</span> which proxies any calls made on HelloWorldSpringService to an instance of HelloWorldSpringService on the fabric. The concept behind <span style="font-family: 'Courier New';">FabricProxyFactoryBean</span> is very similar to Spring Remoting. Infact <span style="font-family: 'Courier New';">FabricProxyFactoryBean</span> uses Spring Remoting classes to proxy requests to the fabric.<br />
The <span style="font-family: 'Courier New';">FabricProxyFactoryBean</span> requires:</p>
<ul>
<li>the interface on which methods will be called,</li>
<li>a reference to <span style="font-family: 'Courier New';">com.appistry.fabric.Fabric</span>,</li>
<li>an applicationName which should match the <span style="font-family: 'Courier New';">name</span> attribute of the <span style="font-family: 'Courier New';">app</span> element in the fabric application definition xml (<span style="font-family: 'Courier New';">springHWSvc-fabric-app-defn.xml</span>),</li>
<li>a componentName which should match the <span style="font-family: 'Courier New';">name</span> attribute of the <span style="font-family: 'Courier New';">component</span> element in the component definition xml (springHWSvc-component-defn.xml).</li>
</ul>
<p>Let&#8217;s now add some code to <span style="font-family: 'Courier New';">HelloWorldSpringClient</span> to call the <span style="font-family: 'Courier New';">fabricHelloWorldBean</span> that we just defined above<big>.<br />
</big><br />
Let&#8217;s append the following two lines to the HelloWorldSpringClient&#8217;s main method:</p>
<pre class="java-codeface">HelloWorldSpringService fabricHWS = (HelloWorldSpringService) appContext.getBean("fabricHelloWorldBean");
System.out.println(fabricHWS.greet("from the fabric."));</pre>
<p>Now we are ready to run HelloWorldSpringClient once again.</p>
<p>From Eclipse, run <span style="font-family: 'Courier New';">HelloWorldSpringClient</span> as a Java Application. You should see an output like this:<big><br />
</big></p>
<blockquote><p><span style="font-family: arial;"><big>&#8230;<br />
&#8230;<br />
</big>Jun 20, 2008 4:35:26 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons<big><br />
</big>INFO:<br />
Pre-instantiating singletons in<br />
org.springframework.beans.factory.support.DefaultListableBeanFactory@18a7efd:<br />
defining beans [localHelloWorldBean,fabricHelloWorldBean,fabric]; root<br />
of factory hierarchy<big><br />
</big>Hello World, locally.<strong><small><big><br />
Hello World, from the fabric.</big><br />
</small></strong></span></p></blockquote>
<p>The HelloWorldSpringClient application loads the <span style="font-family: 'Courier New';">helloWorldClient-appContext.xml</span> spring application context, gets a reference to the <span style="font-family: 'Courier New';">fabricHelloWorldBean</span> and calls the greet method on it. The FabricProxyFactoryBean proxies the greet request to the fabric. An instance of HelloWorldSpringServiceBean on the fabric executes the greet method and returns the results to the HelloWorldSpringClient which prints the result to the standard out.</p>
<p>As you can see, we haven&#8217;t changed any code on the client either. Just a little bit of configuration and that was it.</p>
<p><strong>Download</strong></p>
<p>Extract the contents of the zip into your eclipse workspace. This will create a HelloWorldSpring folder under your workspace.</p>
<p><small><a title="HelloWorldSpring-source.zip" href="http://blogs.plexibus.com/wp-content/uploads/2008/06/helloworldspring-source.zip">HelloWorldSpring-source.zip</a><br />
</small></p>
<p><strong>Appistry EAF Developer Portal</strong></p>
<p>To learn more visit the <a href="http://www.appistry.com/developers/">Appistry EAF Developer Portal</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.plexibus.com/2008/06/21/code-example-using-spring-beans-with-appistry-eaf-38/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nexus &#8211; Maven Repository Manager</title>
		<link>http://blogs.plexibus.com/2008/04/22/nexus-maven-repository-manager/</link>
		<comments>http://blogs.plexibus.com/2008/04/22/nexus-maven-repository-manager/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 04:10:22 +0000</pubDate>
		<dc:creator>roshanallan</dc:creator>
				<category><![CDATA[Build]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[corporate maven repository]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[maven proxy]]></category>
		<category><![CDATA[maven proxy server]]></category>
		<category><![CDATA[maven repository]]></category>
		<category><![CDATA[maven repository manager]]></category>
		<category><![CDATA[maven2]]></category>
		<category><![CDATA[nexus]]></category>
		<category><![CDATA[plexibus]]></category>
		<category><![CDATA[repository]]></category>
		<category><![CDATA[repository manager]]></category>
		<category><![CDATA[roshan]]></category>
		<category><![CDATA[sequeira]]></category>
		<category><![CDATA[sonatype nexus]]></category>

		<guid isPermaLink="false">http://blogs.plexibus.com/2008/04/22/nexus-maven-repository-manager/</guid>
		<description><![CDATA[I installed Nexus on my Ubuntu server last weekend. So far it&#8217;s works great. Their single page documentation was very helpful during installation and configuration
I use Artifactory at my work place. And I&#8217;ve attempted using Archiva at home. But after installing Nexus, I prefer it over Artifactory and Archiva.
Here are a few reason why I [...]]]></description>
			<content:encoded><![CDATA[<p>I installed <a href="http://nexus.sonatype.org/">Nexus</a> on my Ubuntu server last weekend. So far it&#8217;s works great. Their <a href="http://www.sonatype.com/book/reference/repository-manager.html">single page documentation</a> was very helpful during installation and configuration</p>
<p>I use <a href="http://www.jfrog.org/sites/jfrog/">Artifactory</a> at my work place. And I&#8217;ve attempted using <a href="http://maven.apache.org/archiva/">Archiva</a> at home. But after installing Nexus, I prefer it over Artifactory and Archiva.</p>
<p>Here are a few reason why I prefer Nexus over Artifactory and Archiva:</p>
<ol>
<li>I can control (add/update/remove) repositories via the UI without having to remote into my linux box and edit an xml file like I would have to do when using Artifactory.</li>
<li>Upgrading to a higher version of Nexus is simply a matter of unzipping the newer version, renaming the older version, and creating a soft link to the new version. I don&#8217;t have to bother exporting/importing data like in Artifactory.</li>
<li>The downloaded artifacts are stored on the file system (under $NEXUS_HOME/runtime/work/nexus/storage), and well organized into &#8220;repository-named folders&#8221; such as &#8220;central&#8221; (artifact downloaded from http://repo1.maven.org). I can now back up the &#8220;storage&#8221; directory easily.</li>
<li>Searching for artifacts using Nexus is fast. Searching with Artifactory was/is a pain &#8211; poor implementation of &#8220;google-like suggest&#8221; Ajax feature.</li>
<li>Installing Archiva to run as a war file in Tomcat is a pain. Archiva expects you to create an &#8220;archiva&#8221; folder under the $CATALINA_HOME directory. What the heck???? And the documentation seems lacking.</li>
<li>And oh, did I mention the slick UI ( <a href="http://extjs.com/">Ext JS</a>) that is provided by Nexus. It is far better than Artifactory, and Archiva!</li>
</ol>
<p><a href="http://blogs.sonatype.com/people/author/brian/">Brian Fox</a>, a committer of Nexus, discusses some architectural differences between Nexus and Artifactory <a href="http://blogs.sonatype.com/people/2009/01/contrasting-nexus-and-artifactory/">here</a>.</p>
<p>To be fair to Artifactory 2.x, <a href="http://blogs.jfrog.org/2009/01/contrasting-artifactory-and-nexus.html">here</a> is a reply to the above post from the JFrog team, the creators of Artifactory.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.plexibus.com/2008/04/22/nexus-maven-repository-manager/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How to change your local Maven repository</title>
		<link>http://blogs.plexibus.com/2008/03/11/how-to-change-your-local-maven-repository/</link>
		<comments>http://blogs.plexibus.com/2008/03/11/how-to-change-your-local-maven-repository/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 03:04:34 +0000</pubDate>
		<dc:creator>roshanallan</dc:creator>
				<category><![CDATA[Build]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[local maven repository]]></category>
		<category><![CDATA[local repository]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[maven2]]></category>
		<category><![CDATA[repository]]></category>

		<guid isPermaLink="false">http://blogs.plexibus.com/2008/03/11/how-to-change-your-local-maven-repository/</guid>
		<description><![CDATA[By default, the maven repository is created under your user_directory\.m2\repository. On Unix/Linux, this is fine. But under Windows, I prefer a different location than the default which is &#8220;C:\Documents and Settings\&#60;user_directory&#62;\.m2\repository&#8221;.
You can change where Maven creates the repository. Open the settings.xml in your $M2_HOME/conf directory and change the localRepository element to point to the directory [...]]]></description>
			<content:encoded><![CDATA[<p>By default, the maven repository is created under your <strong>user_directory\.m2\repository</strong>. On Unix/Linux, this is fine. But under Windows, I prefer a different location than the default which is &#8220;C:\Documents and Settings\&lt;user_directory&gt;\.m2\repository&#8221;.</p>
<p>You can change where Maven creates the repository. Open the settings.xml in your $M2_HOME/conf directory and change the <strong>localRepository</strong> element to point to the directory where you want Maven to download artifacts to.</p>
<p>That&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.plexibus.com/2008/03/11/how-to-change-your-local-maven-repository/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Maven Guide &#8211; Basics</title>
		<link>http://blogs.plexibus.com/2007/12/02/maven-guide-part-one-basics/</link>
		<comments>http://blogs.plexibus.com/2007/12/02/maven-guide-part-one-basics/#comments</comments>
		<pubDate>Mon, 03 Dec 2007 02:53:39 +0000</pubDate>
		<dc:creator>roshanallan</dc:creator>
				<category><![CDATA[Build]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[benefits of maven]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[maven basics]]></category>
		<category><![CDATA[maven examples]]></category>
		<category><![CDATA[maven tutorial]]></category>
		<category><![CDATA[maven vs ant]]></category>
		<category><![CDATA[maven2]]></category>

		<guid isPermaLink="false">http://blogs.plexibus.com/?p=5</guid>
		<description><![CDATA[I created this document for my team at work when I migrated all our ant builds to maven.
What is Maven
Maven is more than a build tool. It&#8217;s is a project management tool. Maven&#8217;s power lies in it approach &#8211; standards over flexibility &#8211; and code reusability using plugins.
Maven Principles

Convention over configuration
Declarative execution
Reuse of build logic
Coherent [...]]]></description>
			<content:encoded><![CDATA[<p>I created this document for my team at work when I migrated all our ant builds to maven.</p>
<p><strong>What is Maven</strong><br />
Maven is more than a build tool. It&#8217;s is a project management tool. Maven&#8217;s power lies in it approach &#8211; standards over flexibility &#8211; and code reusability using plugins.</p>
<p><strong>Maven Principles</strong></p>
<ul>
<li>Convention over configuration</li>
<li>Declarative execution</li>
<li>Reuse of build logic</li>
<li>Coherent organization of dependencies</li>
</ul>
<p>Using standard conventions saves time, makes it easier to communicate to others, and allows you to create value in your applications faster with less effort.</p>
<p>There are three primary conventions that Maven employs to promote a standardized development environment:</p>
<ul>
<li>Standard directory layout for projects</li>
<li>The concept of a single Maven project producing a single output</li>
<li>Standard naming conventions</li>
</ul>
<p><strong>Why we are migrated to Maven from Ant builds</strong><br />
Using Ant we ran into the following issues:</p>
<ul>
<li>Lack of common approach OR copy, paste, edit approach</li>
<li>A lot of time spent by developers configuring the build</li>
<li>Any changes to project structure would mean changes to build and more configuration</li>
<li>Configuring multi-module projects and dependencies were a huge task and required build expertise</li>
<li>Not everyone knows how to write Ant build scripts</li>
</ul>
<p>So despite creating and encapsulating the common tasks such as compile, compile-tests, run-tests, etc. into a build-common.xml Ant build file, it still wasn&#8217;t enough. By the way, in Maven, you don&#8217;t need to write common tasks as the above. All these come bundled via plugins in Maven. Behold the power of Maven plugins. Shout Hallelujah!</p>
<p>Maven can prove to be indispensable and IMHO, brings more value and speed than Ant when starting a new team and new projects. For example, one would not need to spend time creating, encapsulating, and testing the common tasks in a build-common.xml.</p>
<p>Of course, the previous statement/paragraph is not intended to downplay the benefits and value that Maven provides to projects migrating from Ant as you will see shortly.</p>
<p>Before we move on, it would be worth mentioning that &#8220;Standards over Flexibility&#8221; does not imply that Maven isn&#8217;t extensible. You may override some or all of the defaults &#8211; for example, you may choose to change the default directory names or change the default lifecycle &#8211; but it may prove to be counter productive and time-consuming in the long run. To quote Jerry Seinfeld,</p>
<blockquote><p>&#8220;The road less traveled is less traveled for a reason&#8221;.</p></blockquote>
<p><strong>Maven Build Life Cycle</strong></p>
<p>Every project follows a certain execution path or a process for building and distributing a particular artifact. Maven has standardized this process so that it is only necessary to learn a small set of commands to build any Maven project.</p>
<p><strong>Lifecyle Phases</strong> &#8211; Description<br />
<strong>validate</strong> &#8211; validate the project is correct and all necessary information is available<br />
<strong>generate-sources</strong> &#8211; generate any source code for inclusion in compilation.<br />
<strong>process-sources</strong> &#8211; process the source code, for example to filter any values.<br />
<strong>generate-resources</strong> &#8211; generate resources for inclusion in the package.<br />
<strong>process-resources</strong> &#8211; copy and process the resources into the destination directory, ready for packaging.<br />
<strong>compile</strong> &#8211; compile the source code of the project.<br />
<strong>process-classes</strong> &#8211; post-process the generated files from compilation, for example to do bytecode enhancement on Java classes.<br />
<strong>generate-test-sources</strong> &#8211; generate any test source code for inclusion in compilation.<br />
<strong>process-test-sources</strong> &#8211; process the test source code, for example to filter any values.<br />
<strong>generate-test-resources</strong> &#8211; create resources for testing.<br />
<strong>process-test-resources</strong> &#8211; copy and process the resources into the test destination directory.<br />
<strong>test-compile</strong> &#8211; compile the test source code into the test destination directory.<br />
<strong>test</strong> &#8211; run tests using a suitable unit testing framework. should not require the code be packaged or deployed.<br />
<strong>prepare-package</strong> &#8211; perform any operations necessary to prepare a package before the actual packaging. This often results in an unpacked, processed version of the package. (Maven 2.1 and above)<br />
<strong>package</strong> &#8211; take the compiled code and package it in its distributable format, such as a JAR.<br />
<strong>pre-integration-test</strong> &#8211; perform actions required before integration tests are executed. This may involve things such as setting up the required environment.<br />
<strong>integration-test</strong> &#8211; process and deploy the package if necessary into an environment where integration tests can be run.<br />
<strong>post-integration-test</strong> &#8211; perform actions required after integration tests have been executed. This may including cleaning up the environment.<br />
<strong>verify</strong> &#8211; run any checks to verify the package is valid and meets quality criteria.<br />
<strong>install</strong> &#8211; install the package into the local repository, for use as a dependency in other projects locally.<br />
<strong>deploy</strong> &#8211; done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.<br />
<strong>clean</strong> &#8211; cleans up artifacts created by prior builds.<br />
<strong>site</strong> &#8211; generates site documentation for this project.<br />
How do you execute a certain lifecycle phase? By default this is specified in the POM. The &#8220;packaging&#8221; element in the POM defines the phase to execute and by default it is &#8220;jar&#8221;. So Maven will execute the above phases starting with validate up to and including packaging (jar). You can add extension points or customize your build lifecycle by configuring existing plugins or creating and adding your own plugin. You can also run a certain phase from the command line as:</p>
<blockquote><p><code>mvn compile</code></p></blockquote>
<p>The above will run all phases from validate up to and including the compile phase. A <em>phase</em> is a step in the build lifecycle. Phases are mapped to underlying <em>goals</em>. You can even execute a certain goal in a phase. For example,</p>
<blockquote><p><code>mvn archetype:create -DgroupId=com.plexibus -DartifactId=com.plexibus.common</code></p></blockquote>
<p>The above goal will create a directory with the same name given as the artifactId or in other words a new Java project with a standard structure as espoused by Maven. You can execute multiple phases as well:</p>
<blockquote><p><code>mvn clean compile</code></p></blockquote>
<p><strong>Maven Standard Directory structure</strong></p>
<p><strong>Files</strong> &#8211; Description<br />
<strong>src/main/java</strong> &#8211; Application/Library sources<br />
<strong>src/main/resources</strong> &#8211; Application/Library resources<br />
<strong>src/main/filters</strong> &#8211; Resource filter files<br />
<strong>src/main/assembly</strong> &#8211; Assembly descriptors<br />
<strong>src/main/config</strong> &#8211; Configuration files<br />
<strong>src/test/java</strong> &#8211; Test sources<br />
<strong>src/test/resources</strong> &#8211; Test resources<br />
<strong>src/test/filters</strong> &#8211; Test resource filter files<br />
<strong>LICENSE.txt</strong> &#8211; Project&#8217;s license<br />
<strong>README.txt</strong> &#8211; Project&#8217;s readme<br />
<strong>target</strong> &#8211; Generated output directory</p>
<p><strong>Project Object Model</strong></p>
<p>The POM is defined in a pom.xml file that contains all the information necessary to build the project, generate reports, and configure plugins. An example POM is show below:</p>
<pre class="xml-codeface">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>for</groupId>
	<artifactId>bar</artifactId>
<packaging>jar</packaging>
	<version>1.0.0-SNAPSHOT</version>
	<name>bar</name>
	<url />
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.4</version>
			<scope>test</scope>
		</dependency>
	</dependencies>
</project
</pre>
<p>Maven model: <a href="http://maven.apache.org/ref/2.0.8/maven-model/maven.html">http://maven.apache.org/ref/2.0.8/maven-model/maven.html</a></p>
<p><strong>Maven Repositories</strong></p>
<p>There are three types of Maven repositories</p>
<ul>
<li><em>Local repository on the developer machine</em>. This is usually located at ${user.dir}/.m2/repository</li>
<li><em>Shared internal repository or Corporate repository</em>. <a href="http://www.jfrog.org/sites/artifactory/latest/">Artifactory</a> is a decent tool that can be used as a corporate repository</li>
<li><em>Public repository</em>. By default you are pointed to http://repo1.maven.org/maven2. Although you can add additional repositories by configuring Maven (settings.xml), you should follow the standard operating practice that is point your Maven install to your organization's corporate Repository. Repositories are essentially directories with a certain structure.</li>
</ul>
<p><strong>Installing Maven</strong><br />
Download and install maven from <a href="http://maven.apache.org/download.html">here</a>. Once you have installed it, add an environment variable</p>
<blockquote><p><code>M2_HOME=&lt;MAVEN_INSTALL_DIR&gt;</code></p></blockquote>
<p>Edit the settings.xml in $M2_HOME/conf to point to your organization's corporate Repository.</p>
<p><strong>Maven frequently used commands</strong></p>
<p>Create a new project</p>
<pre class="xml-codeface">
mvn archetype:create -DgroupId=foo -DartifactId=bar
</pre>
<p>or</p>
<pre class="xml-codeface">
mvn archetype:generate -DgroupId=foo -DartifactId=bar -B
</pre>
<p>or</p>
<pre class="xml-codeface">
mvn archetype:generate -DgroupId=foo -DartifactId=bar -Darchetype.interactive=false
</pre>
<p>Create a new web application project</p>
<pre class="xml-codeface">
mvn archetype:create -DgroupId=foo -DartifactId=barwebapp -DarchetypeArtifactId=maven-archetype-webapp
</pre>
<p>Clean up generated artifacts</p>
<pre class="xml-codeface">
mvn clean
</pre>
<p>Clean and compile the project</p>
<pre class="xml-codeface">
mvn clean compile
</pre>
<p>Clean, compile, and run unit tests</p>
<pre class="xml-codeface">mvn clean compile test</pre>
<p>Clean, compile and package to create an artifact (default jar)</p>
<pre class="xml-codeface">mvn clean package</pre>
<p>Clean, package up the artifact and install it into your local repository</p>
<pre class="xml-codeface">mvn clean package install</pre>
<p>Clean, package up the artifact and generate a website (documentation)</p>
<pre class="xml-codeface">mvn clean package site</pre>
<p>Generate Eclipse IDE settings</p>
<pre class="xml-codeface">mvn eclipse:clean eclipse:eclipse -DdownloadSources=true</pre>
<p><strong>Creating a simple project in Maven</strong></p>
<pre class="xml-codeface">mvn archetype:create -DgroupId=foo -DartifactId=bar</pre>
<p>Maven will create a directory with the name "bar". Change to the "bar" directory and you will see a generated pom.xml, and "src" directory with sub-directories such as "src/main", "src/main/java", "src/test", "src/test/java".</p>
<p><strong>Multi-module project</strong><br />
Multi-module projects are slightly different in that each module (parent included) has a pom.xml.</p>
<p>Say you want a directory structure like:</p>
<blockquote><p>bar<br />
|-&gt; baz<br />
|-&gt; bam</p></blockquote>
<pre class="xml-codeface">mvn archetype:create -DgroupId=foo -DartifactId=bar</pre>
<p>This will create a "bar" sub-directory with a "pom.xml" and "src" sub-directory.<br />
Change to the "bar" sub-directory and delete the "src" folder. Edit the pom.xml. Change the packaging element to "pom" instead of "jar".<br />
Now from within the "bar" directory, execute the following command:</p>
<pre class="xml-codeface">
mvn archetype:create -DgroupId=bar -DartifactId=baz
mvn archetype:create -DgroupId=bar -DartifactId=bam
</pre>
<p>This will create the following modules (directories), "baz" and "bam" with their own pom.xml files and "src" sub-directories. You will also notice that the parent pom.xml (in "bar" directory) has been updated to reflect the child modules: "baz" and "bam".</p>
<p>You can now build "bar" which will in turn build the child modules "baz" and "bam"</p>
<pre class="xml-codeface">mvn clean package</pre>
<p>The parent pom (in bar) is inherited by the sub module poms. So you could effectively define global elements such as dependency like "junit" in the parent pom which will be inherited by the sub module poms. A good case for reuse and reduced redundancy. Defining the same element in the sub module will override the element definition in the parent module.</p>
<p><strong>Maven and setting up Eclipse</strong><br />
Eclipse needs to know the path to the local maven repository. Therefore the classpath variable <strong>M2_REPO</strong> has to be set.</p>
<ol>
<li>Select Window &gt; Preferences. Select Java &gt; Build Path &gt; Classpath Variables.</li>
<li>Create a new M2_REPO variable and point it to your $\{user.dir\}/.m2/repository folder.</li>
<li>Next, from the menu bar, select Window &gt; Preferences. Select the Run/Debug &gt; String Substitution. Add a new variable e.g. <em>maven_exec</em>.</li>
<li>When you set up a new external launcher (from the menu bar, select Run &gt; External Tools. Select Program) you can refer to <em>maven_exec</em> in the "Location" field. And add $\{project_loc\} to the "Working Directory" field. And then specify the maven goals of your choice in the arguments such as: clean package</li>
<li>You can set up multiple launch configurations such "clean, compile", "clean package site", "clean package install", etc.</li>
</ol>
<p><strong>Deploying artifacts to Corporate Repository</strong></p>
<p>If you want to deploy a certain artifact or an artifact that isn't available yet in one of the public remote repositories, you can do the following:</p>
<pre class="xml-codeface">mvn deploy:deploy-file -DrepositoryId=artifactory
-Durl=http://somerepository.com
-DgroupId=com.ibm.mq -DartifactId=com.ibm.mqjms -Dversion=5.3
-Dpackaging=jar -Dfile=com.ibm.mqjms.jar
</pre>
<p>*Note:* You should never have to use the deploy command since you should have your continuous integration tool deploy the artifacts to your organization's corporate repository.</p>
<p><strong>Maven Global and User settings</strong><br />
Maven has two settings files, one in the Maven installation directory (under conf) - settings.xml (global settings), and one in the user's home directory. They are merged, and the latter overrides anything in the former. If you want to override the global settings you could pass an additional parameter (-Dorg.apache.maven.global-settings) when you run maven commands as follows:</p>
<pre class="xml-codeface">
mvn clean install -Dorg.apache.maven.global-settings=c:\new_global_settings.xml
</pre>
<p>Note that you are only overriding the global settings here. Therefore if you have a user settings xml, that will still be applied. The -D argument above is deprecated in 2.1.x. Use -gs instead.</p>
<pre class="xml-codeface">
mvn clean install -gs c:\new_global_settings.xml
</pre>
<p>If you want to override user settings, you could pass the new user settings as follows:</p>
<pre class="xml-codeface">
mvn clean install -s c:\new_user_settings.xml
</pre>
<p><strong>Tagging, Branching, Releasing using Maven</strong><br />
Coming soon!</p>
<p><strong>Troubleshooting tips</strong></p>
<p><strong>Maven help</strong></p>
<pre class="xml-codeface">mvn --help</pre>
<p><strong>OutOfMemoryError</strong><br />
If you are getting OutOfMemoryErrors when doing a build, try increasing the max heap and PermGen space sizes. You can do this by setting the MAVEN_OPTS variable</p>
<pre class="xml-codeface">
set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=256m
export MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=256m
</pre>
<p><strong>Debug</strong><br />
The debug option is very useful when you find yourself in "classloader hell"(conflicting library versions or unwanted jars in your classpath). The debug option makes it easy to see where each library is coming from</p>
<pre class="xml-codeface">
mvn -X
</pre>
<p><strong>Debugging test failures</strong><br />
Surefire, which is the default Maven test runner, outputs all reports as a set of xml and text files. Any test failure details and stacktraces end up in those files and not the console. The output can be redirected to the console temporarily by adding the following option</p>
<pre class="xml-codeface">
mvn -Dsurefire.useFile=false
</pre>
<p><strong>Non-recursive option</strong><br />
Executing a Maven goal for a module will default execute the goal for any modules below it in the heirarchy. If you specifically wish to run the goal for this module only (and not it's children) you can use the non-recursive option:</p>
<pre class="xml-codeface">
mvn -N
</pre>
<p><strong>Skip compiling unit tests</strong></p>
<pre class="xml-codeface">
mvn -Dmaven.test.skip=true
</pre>
<p><strong>Skip running unit tests</strong></p>
<pre class="xml-codeface">
mvn -DskipTests
</pre>
<p>or you could set the skipTests property (maven-surefire-plugin configuration) to true in the pom</p>
<p><strong>Ignore (do not fail) on test failures</strong><br />
This could be useful when you don't want builds to fail, such as clover builds.</p>
<pre class="xml-codeface">
mvn -Dmaven.test.failure.ignore=true
</pre>
<p><strong>Generating clover reports without generating site</strong><br />
The following command will generate clover reports without generating the entire website.</p>
<pre class="xml-codeface">
mvn clover:instrument clover:clover
</pre>
<p><strong>Move Local Maven Repository</strong><br />
See <a href="http://blogs.plexibus.com/2008/03/11/how-to-change-your-local-maven-repository/">here</a> on how to do this.</p>
<p><strong>References</strong><br />
<a href="htt://maven.apache.org">htt://maven.apache.org</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.plexibus.com/2007/12/02/maven-guide-part-one-basics/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tagging and branching with the Maven release plugin &#8211; a few pain points</title>
		<link>http://blogs.plexibus.com/2007/11/22/tagging-and-branching-with-the-maven-release-plugin-a-few-pain-points/</link>
		<comments>http://blogs.plexibus.com/2007/11/22/tagging-and-branching-with-the-maven-release-plugin-a-few-pain-points/#comments</comments>
		<pubDate>Thu, 22 Nov 2007 18:44:39 +0000</pubDate>
		<dc:creator>roshanallan</dc:creator>
				<category><![CDATA[Build]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[maven release]]></category>
		<category><![CDATA[maven release plugin]]></category>
		<category><![CDATA[maven2]]></category>
		<category><![CDATA[plexibus]]></category>
		<category><![CDATA[roshan]]></category>
		<category><![CDATA[sequeira]]></category>

		<guid isPermaLink="false">http://blogs.plexibus.com/?p=4</guid>
		<description><![CDATA[I&#8217;m currently working on setting up and configuring the Maven release plugin on our projects for doing releases &#8211; primarily tagging, branching, and deploying a tagged release.
We have been using Maven extensively and I&#8217;ve been for the most part happy with it since we migrated from Ant. I say *most* since there have been a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently working on setting up and configuring the <a href="http://maven.apache.org/plugins/maven-release-plugin/">Maven release plugin</a> on our projects for doing releases &#8211; primarily tagging, branching, and deploying a tagged release.</p>
<p>We have been using Maven extensively and I&#8217;ve been for the most part happy with it since we migrated from Ant. I say *most* since there have been a couple of times where Maven didn&#8217;t work as expected or documented. For example, in the current case, with the Maven release plugin.</p>
<p>Most of our projects are setup as multi-module projects with a parent pom and children jars. The Maven release plugin behaviour is suspect with multi-module projects.</p>
<p>For example, say I had project with &#8220;bar&#8221; as the parent and &#8220;baz&#8221;, &#8220;bam&#8221; and &#8220;dist&#8221; as the children modules. And &#8220;bam&#8221; has &#8220;baz&#8221; as a dependency. &#8220;dist&#8221; does the assembly using the <a href="http://maven.apache.org/plugins/maven-assembly-plugin/">Maven assembly plugin</a>.</p>
<p>Running the following command on the &#8220;bar&#8221; tags the release fine:<br />
<code>mvn release:clean release:prepare</code><br />
but fails during the following command which checks out the tagged release from our SCM and attempts to build it:<br />
<code>mvn release:perform</code></p>
<p>During release:perform, Maven first checks out the code using the above tag and then attempts to build (deploy goal) the checked out code (under <em>bar/target/checkouts</em> folder) using the command:<br />
<code><br />
deploy --no-plugin-updates -P defaultRepo -DreleasePerform=true -f pom.xml<br />
</code><br />
During the build, Maven attempts to download the <em>release</em> version of &#8220;baz&#8221; since it&#8217;s defined as a dependency in &#8220;bam&#8221; pom. Of course, this fails! <em>Because &#8220;baz&#8221; isn&#8217;t available as a release yet</em>.</p>
<p>After a &#8220;few gnashing of teeth and pulling of the hair&#8221; moments, I noticed that this is caused by the &#8220;-DreleasePerform=true&#8221; variable in the above command that Maven uses internally once I issued the &#8220;mvn release:perform&#8221; command. Take &#8220;-Drelease:perform=true&#8221; out, the <code>release:perform</code> works great.</p>
<p>To get past this issue, I had to override the default &#8220;preparationGoals&#8221; element of the Maven release plugin. The default preparationGoals are <code>clean verify</code>. Adding <code>install</code> after <code>verify</code> built the release jars during the <code>release:prepare</code> goal and installed it to my local Maven repository. So now when I run the <code> mvn release:perform</code> command, it downloads the &#8220;baz&#8221; dependency from my local Maven repository.</p>
<p>A few other things I didn&#8217;t like:</p>
<p><strong>1. Why can I not have 3rd party SNAPSHOTS in my release?</strong><br />
For example, one of our 3rd party dependencies is org.osgi.compendium, for which a release isn&#8217;t available. Apache Felix has only made it available as a SNAPSHOT. Having this SNAPSHOT as a dependency doesn&#8217;t go well with the Maven release plugin. It complains that there are SNAPSHOT dependencies and they need to be resolved to <em>released</em>. I know there are SNAPSHOT dependencies and I intentionally left them there since I don&#8217;t have *release* versions.<br />
IMHO, there should be a setting to override this *<a href="http://maven.apache.org/plugins/maven-release-plugin/examples/prepare-release.html">Check that there are no SNAPSHOT dependencies</a>* behavior.</p>
<p><strong>2. Why doesn&#8217;t the Maven release plugin reuse the release.properties file that was generated during a dryRun when doing a <code>release:prepare</code>?</strong><br />
I like the concept of a dryRun when during a release:prepare. This gives me the opportunity to verify the changes that will be checked in to my SCM. Running the following command enables me to do this:<br />
<code><br />
mvn release:clean release:prepare -DdryRun=true<br />
</code><br />
The above command generates the temporary pom files and a release.properties file that I can scour through to make sure everything is correct.<br />
Now one would assume that if you run the command:<br />
<code><br />
mvn release:prepare<br />
</code><br />
it would reuse the files that were generated by the previous command <code>mvn release:clean release:prepare -DdryRun=true</code><br />
But it <strong>does not!</strong>. Instead I am prompted to enter the release information again. What if I now mis-typed a letter??<br />
Am I missing something here?</p>
<p><strong>3. &#8211;batch-mode is only good if you want to stick with the versioning provided by the Maven release plugin. Why is customization not supported?</strong><br />
We version our projects as M.N.P<br />
where,<br />
M &#8211; Major release<br />
N &#8211; minor release<br />
P &#8211; patch or bug-fix release<br />
The default versioning used by the Maven release plugin is M.N. Although I understand &#8211;batch-mode is provided to make our lives easier by going with the defaults, it doesn&#8217;t really. Since I&#8217;m stuck with the versioning standards provided by Maven. I like the <em>&#8220;convention over configuration&#8221;</em> approach. But by not allowing room for customization doesn&#8217;t help.</p>
<p>Apart from the above pain points, the Maven release plugin seems to do it&#8217;s job for us. We are planning on using it for now until something better comes up since it certainly bring some order to the chaotic world of <em>tagging, branching and releasing</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.plexibus.com/2007/11/22/tagging-and-branching-with-the-maven-release-plugin-a-few-pain-points/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.567 seconds -->
