<?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>Den Of Ubiquity &#187; jruby</title>
	<atom:link href="http://www.denofubiquity.com/tag/jruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.denofubiquity.com</link>
	<description>Buzzword-enriched Software Development Content</description>
	<lastBuildDate>Sun, 27 Sep 2009 20:10:41 +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>Barbler: Integrating JRuby Warbler into Apache Builder</title>
		<link>http://www.denofubiquity.com/ruby/barbler/</link>
		<comments>http://www.denofubiquity.com/ruby/barbler/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 21:54:14 +0000</pubDate>
		<dc:creator>ijonas</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[buildr]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[war]]></category>
		<category><![CDATA[warbler]]></category>

		<guid isPermaLink="false">http://www.denofubiquity.com/?p=319</guid>
		<description><![CDATA[After having used Apache Builder for a week and extracted our Warbler-code into a bonafide extension, I&#8217;m sharing it with the community under the fetching name Barbler.
Barbler integrates itself between the build and packaging stages of the Apache Builder lifecycle and makes calls into Warbler to automate WAR-file creation. Now Warbler does a really good [...]]]></description>
			<content:encoded><![CDATA[<p>After having used Apache Builder for a week and extracted our Warbler-code into a bonafide extension, I&#8217;m sharing it with the community under the fetching name <strong>Barbler</strong>.</p>
<p>Barbler integrates itself between the build and packaging stages of the Apache Builder lifecycle and makes calls into Warbler to automate WAR-file creation. Now Warbler does a really good job for packaging standalone Rails apps. Unfortunately I needed something more integrated into our application build process, that pulls in our Spring Framework-based Java code, Scala code, and Rails application and produces a single WAR-file containing all dependent libraries, Rails code, XML deployment descriptors and Java class files. Apache Builder does everything other than the Rails-packaging. Barbler steps to provide that missing step.</p>
<p>Create a barbler.rb file in your project folder, which also contains your buildfile and copy the following contents into it:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Barbler </span>
<span style="color:#008000; font-style:italic;"># is an Apache Builder extension to integrate the JRuby Warbler gem.</span>
<span style="color:#008000; font-style:italic;"># For tips on how to use Barbler checkout http://www.denofubiquity.com/ruby/barbler/</span>
<span style="color:#008000; font-style:italic;"># </span>
<span style="color:#008000; font-style:italic;"># This code is licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.txt)</span>
<span style="color:#008000; font-style:italic;"># Please distribute Barbler code with this code intact.</span>
<span style="color:#008000; font-style:italic;"># (c) Ijonas Kisselbach 2009</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'warbler'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">module</span> Barbler
  <span style="color:#9966CC; font-weight:bold;">include</span> Extension
&nbsp;
  first_time <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#008000; font-style:italic;"># Define task not specific to any projet.</span>
    desc <span style="color:#996600;">'Warbles Rails sourcecode tree into a staging folder'</span>
    Project.<span style="color:#9900CC;">local_task</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'warble'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'build'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>name<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#996600;">&quot;Warbling #{name}&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>   
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  before_define <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>project<span style="color:#006600; font-weight:bold;">|</span>    
    project.<span style="color:#9900CC;">task</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'warble'</span><span style="color:#006600; font-weight:bold;">=&gt;</span>project.<span style="color:#9900CC;">task</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'build'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    project.<span style="color:#9900CC;">group</span> <span style="color:#006600; font-weight:bold;">||</span>= project.<span style="color:#9900CC;">parent</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> project.<span style="color:#9900CC;">parent</span>.<span style="color:#9900CC;">group</span> <span style="color:#006600; font-weight:bold;">||</span> project.<span style="color:#9900CC;">name</span>
    project.<span style="color:#9900CC;">version</span> <span style="color:#006600; font-weight:bold;">||</span>= project.<span style="color:#9900CC;">parent</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> project.<span style="color:#9900CC;">parent</span>.<span style="color:#9900CC;">version</span>    
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># To use this method in your project:</span>
  <span style="color:#008000; font-style:italic;">#   warble(:rails =&gt; path_to(:rails), :tasks =&gt; [:app, :public])</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> warble<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>args<span style="color:#006600; font-weight:bold;">&#41;</span>
    options = args.<span style="color:#9900CC;">pop</span>
    rails_path = options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:rails</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    warble_tasks = options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:tasks</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># Define the warble task for this particular project.</span>
    <span style="color:#6666ff; font-weight:bold;">Rake::Task</span>.<span style="color:#9900CC;">define_task</span> <span style="color:#996600;">'warble'</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>task<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#008000; font-style:italic;"># get all the important components from the Rails GUI into the staging directory</span>
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Warbling #{rails_path}&quot;</span>
      <span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">chdir</span><span style="color:#006600; font-weight:bold;">&#40;</span>rails_path<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
        warble_cfg = <span style="color:#CC0066; font-weight:bold;">eval</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;config/warble.rb&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> f.<span style="color:#9900CC;">read</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#6666ff; font-weight:bold;">Warbler::Task</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:war</span>, warble_cfg<span style="color:#006600; font-weight:bold;">&#41;</span>
        warble_tasks.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>task<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#6666ff; font-weight:bold;">Rake::Task</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;war:#{task}&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">invoke</span><span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#6666ff; font-weight:bold;">Buildr::Project</span>
  <span style="color:#9966CC; font-weight:bold;">include</span> Barbler
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Add the folllowing line to the top of your buildfile:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">warble<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:rails</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> path_to<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:rails</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#ff3333; font-weight:bold;">:tasks</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#ff3333; font-weight:bold;">:public</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>You can then define your warble task using the following line</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">warble<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:rails</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> path_to<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:rails</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#ff3333; font-weight:bold;">:tasks</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#ff3333; font-weight:bold;">:public</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p> whereby the first parameter is a path string to where your Rails code is located. You may locate your code in src/main/rails in which case you&#8217;d use</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">warble<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:rails</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> path_to<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:source</span>, <span style="color:#ff3333; font-weight:bold;">:main</span>, <span style="color:#ff3333; font-weight:bold;">:rails</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#ff3333; font-weight:bold;">:tasks</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#ff3333; font-weight:bold;">:public</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>The second parameter is the list of Warbler tasks that you&#8217;d like to have executed. See the Warbler documentation for more help, or check out the Warbler source code &#8211; it&#8217;s very readable.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.denofubiquity.com/ruby/barbler/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Integrating Warbler and Buildr into Scala, JRuby, Java and Rails bliss</title>
		<link>http://www.denofubiquity.com/ruby/integrating-warbler-and-buildr-into-scala-jruby-java-rails-bliss/</link>
		<comments>http://www.denofubiquity.com/ruby/integrating-warbler-and-buildr-into-scala-jruby-java-rails-bliss/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 14:24:25 +0000</pubDate>
		<dc:creator>ijonas</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[apache buildr]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[buildr]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[jruby warbler scala java build apache buildr maven ant]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[warbler]]></category>

		<guid isPermaLink="false">http://www.denofubiquity.com/?p=297</guid>
		<description><![CDATA[At Vamosa we&#8217;re big fans of the Java Virtual Machine. It allows us to use the right tool for the job and deliver a high-quality consistent product for our end-users, whilst still getting the most of our developers. For years we were a .NET and Java shop. Our GUI developers would work in Visual Studio [...]]]></description>
			<content:encoded><![CDATA[<p>At <a href="http://www.vamosa.com">Vamosa</a> we&#8217;re big fans of the Java Virtual Machine. It allows us to use the right tool for the job and deliver a high-quality consistent product for our end-users, whilst still getting the most of our developers. For years we were a .NET and Java shop. Our GUI developers would work in Visual Studio writing a C# application that via SOAP webservices would talk to the Java-backend. In June 2008 we decided to abandon our .NET Desktop GUI and redevelop and expand its functionality, delivered to the end-user&#8217;s browser using HTML+CSS+JavaScript from our Java-backend.</p>
<p>We spend 7months hacking away trying to get Google Web Toolkit to behave before abandoning ship a month ago and switching to Rails. We already had some success building a MRI-based RubyOnRails application called <a href="http://www.vamosa.com/vamosa-check-and-fix-a315">Vamosa Check and Fix</a>. Our GUI developer pool was loving the ease of web development that comes with Rails, and really hated the total lack of productivity from GWT (worthy of a separate post).</p>
<p>Meanwhile I was experimenting with Scala &#8211; IMO the Java language reinvented for the 21st century. So there we were steaming ahead with JRubyOnRails, old-skool Java Spring-based code, and sexy-new Scala code. Three languages, one set of JVM byte code. So how do you build and package all this code ???</p>
<p>Your options are:</p>
<ul>
<li> Apache Maven &#8211; horrible for legacy projects that don&#8217;t build according to Maven doctrine.</li>
<li> Apache Ant + Ivy &#8211; might be an option to you.</li>
<li> Apache Buildr &#8211; JRuby-based build system</li>
</ul>
<p>For us, Apache Buildr had the best fit because its a DSL based-on Rake, which happily runs on JRuby. It provided the dependency management that kept us coming back to Maven (and quickly running away again). It&#8217;s JRuby/Rake-based allowing for tight integration with Warbler, the JRubyOnRails WAR-packaging gem. And lastly there&#8217;s not a shred of XML in sight. Its a DSL, so the buildfile has a nice declarative feel to it, yet can be modified quickly using some standard Ruby-syntax to provide branching and looping. All the other build systems use XML, and then try and retrofit branching and looping, eg. using  elements.</p>
<p>Today we have all our source code in the following folder structure:</p>
<pre>project
src
|-- main
|   |-- java
|   |-- resources
|   |-- scala
|   `-- webapp
`-- test
|-- java
|-- resources
`-- scala

rails
|-- app
|-- config
|-- db
|-- doc
|-- lib
|-- log
|-- nbproject
|-- public
|-- script
|-- test
|-- tmp
`-- vendor</pre>
<p>and our Apache Buildr buildfile in the root of the project tree looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'buildr'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'buildr/scala'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'warbler'</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># define the version of the Vamosa product</span>
VERSION_NUMBER = <span style="color:#996600;">'3.0.0'</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># define repositories from which artifacts can be downloaded</span>
repositories.<span style="color:#9900CC;">remote</span> <span style="color:#006600; font-weight:bold;">&amp;</span>lt;<span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#996600;">'http://www.ibiblio.org/maven2/'</span>
repositories.<span style="color:#9900CC;">remote</span> <span style="color:#006600; font-weight:bold;">&amp;</span>lt;<span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#996600;">'http://scala-tools.org/repo-releases'</span>  <span style="color:#008000; font-style:italic;"># define artifacts that are not available from remote repositories  artifact(&quot;javax.jms:jms:jar:1.1&quot;).from(file(&quot;libs/javax.jms.jar&quot;))  # define the artifacts that the project depends on  SCALA         = group('scala-library', 'scala-compiler', 'axiom-dom', :under=&amp;gt;'org.scala-lang', :version=&amp;gt;'2.7.5')</span>
SCALATEST     = <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#996600;">'org.scala-tools.testing:specs:jar:1.5.0'</span>,<span style="color:#996600;">'org.scalatest:scalatest:jar:0.9.5'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
XUNIT         = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;junit:junit:jar:4.4&quot;</span>, <span style="color:#996600;">&quot;org.dbunit:dbunit:jar:2.2.3&quot;</span>, <span style="color:#996600;">&quot;org.mockito:mockito-all:jar:1.7&quot;</span> <span style="color:#006600; font-weight:bold;">&#93;</span>
JDBC_DRIVERS  = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;mysql:mysql-connector-java:jar:5.1.6&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
HIBERNATE     = <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#996600;">&quot;org.hibernate:hibernate-core:jar:3.3.2.GA&quot;</span>,
  <span style="color:#996600;">&quot;org.hibernate:hibernate-annotations:jar:3.4.0.GA&quot;</span>,
  <span style="color:#996600;">&quot;org.hibernate:hibernate-commons-annotations:jar:3.3.0.ga&quot;</span>,
  <span style="color:#996600;">&quot;org.hibernate:hibernate-search:jar:3.1.0.GA&quot;</span>,
  <span style="color:#996600;">&quot;org.hibernate:hibernate-ehcache:jar:3.3.2.GA&quot;</span>,
  <span style="color:#996600;">&quot;org.hibernate:jtidy-r8:jar:20060801&quot;</span>,
  <span style="color:#996600;">'c3p0:c3p0:jar:0.9.1.2'</span>,
  <span style="color:#996600;">'commons-collections:commons-collections:jar:3.2.1'</span>,
  <span style="color:#996600;">'commons-lang:commons-lang:jar:2.4'</span>,
  <span style="color:#996600;">'net.sf.ehcache:ehcache:jar:1.6.2'</span>,
<span style="color:#996600;">'javax.persistence:persistence-api:jar:1.0'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#008000; font-style:italic;"># DELETED FURTHER ARTIFACTS FOR SAKE OF BREVITY...</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># now lets do some work</span>
platforms = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;mysql&quot;</span>, <span style="color:#996600;">&quot;oracle&quot;</span>, <span style="color:#996600;">&quot;mssql&quot;</span>, <span style="color:#996600;">&quot;db2&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
platform = <span style="color:#996600;">&quot;mysql&quot;</span>
desc <span style="color:#996600;">'Enterprise Content Governance Platform'</span>
define <span style="color:#996600;">'ContentMigrator'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  project.<span style="color:#9900CC;">version</span> = VERSION_NUMBER
  project.<span style="color:#9900CC;">group</span> = <span style="color:#996600;">'com.vamosa'</span>
  manifest<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Copyright'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">'Vamosa Ltd. (C) 2003-2009'</span>
  compile.<span style="color:#9900CC;">options</span>.<span style="color:#9900CC;">target</span> = <span style="color:#996600;">'1.5'</span>
&nbsp;
  compile.<span style="color:#9900CC;">with</span> HIBERNATE, SPRING, COMMONS, LOGGING, CONTENT_PARSER, QUARTZ, J2EE_API, SCRIPTING, SOAP, JFREE_CHART, JAVASSIST, LUCENE, XALAN
  test.<span style="color:#9900CC;">with</span> XUNIT, SCALATEST
  test.<span style="color:#9900CC;">using</span> <span style="color:#ff3333; font-weight:bold;">:scalatest</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># get all the important components from the Rails GUI into the staging directory</span>
  <span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">chdir</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;rails&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Changed current directory to: #{Dir.pwd}&quot;</span>
    warble_cfg = <span style="color:#CC0066; font-weight:bold;">eval</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;config/warble.rb&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> f.<span style="color:#9900CC;">read</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#6666ff; font-weight:bold;">Warbler::Task</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:war</span>, warble_cfg<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#6666ff; font-weight:bold;">Rake::Task</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'war:app'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">invoke</span>
    <span style="color:#6666ff; font-weight:bold;">Rake::Task</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'war:public'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">invoke</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Changed current directory to: #{Dir.pwd}&quot;</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># package it up</span>
  package<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:war</span>, <span style="color:#ff3333; font-weight:bold;">:file</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; _<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;target/#{id}-#{VERSION_NUMBER}-#{platform}.war&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">tap</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>task<span style="color:#006600; font-weight:bold;">|</span>
    task.<span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#996600;">'war/*'</span>
    task.<span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#996600;">&quot;src/main/resources/#{platform}.session-factory.xml&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:as</span>=<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">'WEB-INF/session-factory.xml'</span>
    task.<span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#996600;">'src/main/resources/jboss.jms-context.xml'</span>, <span style="color:#ff3333; font-weight:bold;">:as</span>=<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">'WEB-INF/jms-context.xml'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>The key things we like about this setup are:</p>
<ol>
<li> Easily handling dependency artifacts like the Sun API jars locally. For example we store javax.jms.jar in our Git source repo, in the projects libs/ folder and then point to it using artifact(&#8221;javax.jms:jms:jar:1.1&#8243;).from(file(&#8221;libs/javax.jms.jar&#8221;)).</li>
<li> Integrate Warbler tasks and cherry-pick the ones you want to run, such as in our case just war:app &amp; war:public but e.g. not war:xml because our web.xml is stored in src/main/webapp/WEB-INF instead.</li>
<li> Its Ruby so we can use loops &amp; branching such as:</li>
</ol>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>mssql mysql oracle db2<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>platform<span style="color:#006600; font-weight:bold;">|</span>
  package<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:war</span>, <span style="color:#ff3333; font-weight:bold;">:file</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; _<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;target/#{id}-#{VERSION_NUMBER}-#{platform}.war&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">tap</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>task<span style="color:#006600; font-weight:bold;">|</span>
    task.<span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#996600;">'war/*'</span>
    task.<span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#996600;">&quot;src/main/resources/#{platform}.session-factory.xml&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:as</span>=<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">'WEB-INF/session-factory.xml'</span>
    task.<span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#996600;">'src/main/resources/jboss.jms-context.xml'</span>, <span style="color:#ff3333; font-weight:bold;">:as</span>=<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">'WEB-INF/jms-context.xml'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Apache Buildr isn&#8217;t perfect. There are still some weird annoyances around resolving transitive dependencies, i.e. when hibernate.jar in turn depends on commons-logging.jar. But if you find yourself missing commons-logging.jar its easily added.<br />
If something doesn&#8217;t work they way you think it ought to, you can easily dig into Buildr&#8217;s very readable Ruby code, something I couldn&#8217;t do with either Maven or Ant, and either customise it or find a quick workaround. You don&#8217;t have this black-box barrier between your buildscript and its output.</p>
<p>UPDATE: A nicer way of integrating Warbler and Buildr can be achieved using my Buildr extension, <a href="http://www.denofubiquity.com/ruby/barbler/">Barbler</a>. <a href="http://www.vamosa.com"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.denofubiquity.com/ruby/integrating-warbler-and-buildr-into-scala-jruby-java-rails-bliss/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JRuby-based Chat Server using Terracotta</title>
		<link>http://www.denofubiquity.com/ruby/jruby-based-chat-server-using-terracotta/</link>
		<comments>http://www.denofubiquity.com/ruby/jruby-based-chat-server-using-terracotta/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 05:59:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[clustering]]></category>
		<category><![CDATA[dso]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[terracotta]]></category>

		<guid isPermaLink="false">http://www.denofubiquity.com/?p=261</guid>
		<description><![CDATA[Two technologies are currently capturing my imagination, JRuby and Terracotta. JRuby is simply for my purposes the most effective language to tackle most of my computing challenges. Terracotta allows me to take those problems and solve them on large clusters of cheap servers in clouds such as those provided by Amazon EC2.
Getting started with JRuby+Terracotta [...]]]></description>
			<content:encoded><![CDATA[<p>Two technologies are currently capturing my imagination, <a href="http://kenai.com/projects/jruby/pages/Home">JRuby</a> and <a href="http://www.terracotta.org/">Terracotta</a>. JRuby is simply for my purposes the most effective language to tackle most of my computing challenges. Terracotta allows me to take those problems and solve them on large clusters of cheap servers in clouds such as those provided by Amazon EC2.</p>
<p>Getting started with JRuby+Terracotta requires a bit of trial and error as its not as well documented as good old Java+Terracotta. The only post you’re likely to find is one by Jonas Boner (see below). During subsequent revisions of both Terracotta as well as JRuby, the example had stopped working. These files bring that example update to date for JRuby 1.3.1 and Terracotta 3.0.1.</p>
<p>You can download the revised source code from <a href="http://github.com/ijonas/terracotta-jruby-chat/tree/master">my github account</a>. You will need installs of both JRuby and Terracotta with JRUBY_HOME and TC_HOME pointing to the base folders of both products respectively, e.g.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">JRUBY_HOME</span>=<span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>java<span style="color: #000000; font-weight: bold;">/</span>jruby-1.3.1
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TC_HOME</span>=<span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>java<span style="color: #000000; font-weight: bold;">/</span>terracotta-3.0.1</pre></div></div>

<p>Once these environment variables have been setup you can start a Terracotta server, followed launching multiple clients by typing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>chat.sh</pre></div></div>

<p><strong>Background</strong></p>
<p>The key to fixing the example was fixing the java.lang.NoClassDefFoundError: com/tc/object/event/DmiManager, caused by the references to com.tc.object.bytecode.Manager in the terracotta.rb file:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">WRITE_LOCK = com.<span style="color:#9900CC;">tc</span>.<span style="color:#9900CC;">object</span>.<span style="color:#9900CC;">bytecode</span>.<span style="color:#6666ff; font-weight:bold;">Manager::LOCK_TYPE_WRITE</span>
READ_LOCK = com.<span style="color:#9900CC;">tc</span>.<span style="color:#9900CC;">object</span>.<span style="color:#9900CC;">bytecode</span>.<span style="color:#6666ff; font-weight:bold;">Manager::LOCK_TYPE_READ</span>
CONCURRENT_LOCK = com.<span style="color:#9900CC;">tc</span>.<span style="color:#9900CC;">object</span>.<span style="color:#9900CC;">bytecode</span>.<span style="color:#6666ff; font-weight:bold;">Manager::LOCK_TYPE_CONCURRENT</span></pre></div></div>

<p>Replacing the above fragment with:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">WRITE_LOCK = <span style="color:#006666;">2</span>
READ_LOCK = <span style="color:#006666;">1</span>
CONCURRENT_LOCK = <span style="color:#006666;">4</span></pre></div></div>

<p>and the whole example springs to life. My next problem to solve is that of Rubifying the Workmanager examples from chapter 11 of the &#8220;Definitive Guide to Terracotta&#8221; book.</p>
<p><strong>Useful Links</strong></p>
<ul>
<li><a href="http://jonasboner.com/2007/02/05/clustering-jruby-with-open-terracotta.html">Clustering JRuby with Terracotta</a></li>
<li><a href="http://weblambdazero.blogspot.com/2009/03/incoming-revolution-clojure-terracotta.html">Incoming Revolution: Clojure + Terracotta</a></li>
<li><a href="https://github.com/ijonas/">My github pages</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.denofubiquity.com/ruby/jruby-based-chat-server-using-terracotta/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
