<?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>ijonas.com &#187; warbler</title>
	<atom:link href="http://ijonas.com/tag/warbler/feed/" rel="self" type="application/rss+xml" />
	<link>http://ijonas.com</link>
	<description>Habitual Ramblings of an Indiginous Ijonous</description>
	<lastBuildDate>Mon, 02 Jan 2012 15:12:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Barbler: Integrating JRuby Warbler into Apache Builder</title>
		<link>http://ijonas.com/software-development/ruby/319/</link>
		<comments>http://ijonas.com/software-development/ruby/319/#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 &#8230; <a href="http://ijonas.com/software-development/ruby/319/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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>
<pre lang="ruby"># Barbler
# is an Apache Builder extension to integrate the JRuby Warbler gem.
# For tips on how to use Barbler checkout http://www.denofubiquity.com/ruby/barbler/
#
# This code is licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.txt)
# Please distribute Barbler code with this code intact.
# (c) Ijonas Kisselbach 2009

require 'warbler'

module Barbler
  include Extension

  first_time do
    # Define task not specific to any projet.
    desc 'Warbles Rails sourcecode tree into a staging folder'
    Project.local_task('warble' => 'build') { |name| "Warbling #{name}" }
  end

  before_define do |project|
    project.task('warble'=>project.task('build'))
    project.group ||= project.parent &#038;&#038; project.parent.group || project.name
    project.version ||= project.parent &#038;&#038; project.parent.version
  end

  # To use this method in your project:
  #   warble(:rails => path_to(:rails), :tasks => [:app, :public])
  def warble(*args)
    options = args.pop
    rails_path = options[:rails]
    warble_tasks = options[:tasks]

    # Define the warble task for this particular project.
    Rake::Task.define_task 'warble' do |task|
      # get all the important components from the Rails GUI into the staging directory
      puts "Warbling #{rails_path}"
      Dir.chdir(rails_path) do
        warble_cfg = eval(File.open("config/warble.rb") {|f| f.read})
        Warbler::Task.new(:war, warble_cfg)
        warble_tasks.each {|task| Rake::Task["war:#{task}"].invoke}
      end
    end
  end

end

class Buildr::Project
  include Barbler
end</pre>
<p>Add the folllowing line to the top of your buildfile:</p>
<pre lang="ruby">warble(:rails => path_to(:rails), :tasks => [:app, :public])</pre>
<p>You can then define your warble task using the following line</p>
<pre lang="ruby">warble(:rails => path_to(:rails), :tasks => [:app, :public])</pre>
<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>
<pre lang="ruby">warble(:rails => path_to(:source, :main, :rails), :tasks => [:app, :public])</pre>
<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>
<div style="padding-top:5px;padding-right:0px;padding-bottom:5px;padding-left:0px;;">
											<iframe
												style="height:25px !important; border:0px solid gray !important; overflow:hidden !important; width:460px !important;" frameborder="0" scrolling="no" allowTransparency="true"
												src="http://www.linksalpha.com/social?blog=ijonas.com&link=http%3A%2F%2Fijonas.com%2Fsoftware-development%2Fruby%2F319%2F&title=Barbler%3A+Integrating+JRuby+Warbler+into+Apache+Builder&desc=After+having+used+Apache+Builder+for+a+week+and+extracted+our+Warbler-code+into+a+bonafide+extension%2C+I%27m+sharing+it+with+the+community+under+the+fetching+name+Barbler.%0A%0ABarbler+integrates+itself+betw&fc=333333&fs=arial&fblname=like&fblref=facebook&fbllang=en_US&fblshow=1&fbsbutton=0&fbsctr=1&fbslang=en&fbsendbutton=0&twbutton=1&twlang=en&twmention=ijonas&twrelated1=&twrelated2=&twctr=1&lnkdshow=noshow&lnkdctr=1&buzzbutton=0&buzzlang=en&buzzctr=1&diggbutton=1&diggctr=1&stblbutton=1&stblctr=1&g1button=1&g1ctr=1&g1lang=en-US">
											</iframe>
										</div>]]></content:encoded>
			<wfw:commentRss>http://ijonas.com/software-development/ruby/319/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://ijonas.com/software-development/ruby/297/</link>
		<comments>http://ijonas.com/software-development/ruby/297/#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 &#8230; <a href="http://ijonas.com/software-development/ruby/297/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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>
<pre lang="ruby">require 'buildr'
require 'buildr/scala'
require 'rubygems'
require 'warbler'

# define the version of the Vamosa product
VERSION_NUMBER = '3.0.0'

# define repositories from which artifacts can be downloaded
repositories.remote &lt;&lt; 'http://www.ibiblio.org/maven2/'
repositories.remote &lt;&lt; 'http://scala-tools.org/repo-releases'  # define artifacts that are not available from remote repositories  artifact("javax.jms:jms:jar:1.1").from(file("libs/javax.jms.jar"))  # define the artifacts that the project depends on  SCALA         = group('scala-library', 'scala-compiler', 'axiom-dom', :under=&gt;'org.scala-lang', :version=&gt;'2.7.5')
SCALATEST     = [ 'org.scala-tools.testing:specs:jar:1.5.0','org.scalatest:scalatest:jar:0.9.5']
XUNIT         = ["junit:junit:jar:4.4", "org.dbunit:dbunit:jar:2.2.3", "org.mockito:mockito-all:jar:1.7" ]
JDBC_DRIVERS  = ["mysql:mysql-connector-java:jar:5.1.6"]
HIBERNATE     = [ "org.hibernate:hibernate-core:jar:3.3.2.GA",
  "org.hibernate:hibernate-annotations:jar:3.4.0.GA",
  "org.hibernate:hibernate-commons-annotations:jar:3.3.0.ga",
  "org.hibernate:hibernate-search:jar:3.1.0.GA",
  "org.hibernate:hibernate-ehcache:jar:3.3.2.GA",
  "org.hibernate:jtidy-r8:jar:20060801",
  'c3p0:c3p0:jar:0.9.1.2',
  'commons-collections:commons-collections:jar:3.2.1',
  'commons-lang:commons-lang:jar:2.4',
  'net.sf.ehcache:ehcache:jar:1.6.2',
'javax.persistence:persistence-api:jar:1.0']
# DELETED FURTHER ARTIFACTS FOR SAKE OF BREVITY...

# now lets do some work
platforms = ["mysql", "oracle", "mssql", "db2"]
platform = "mysql"
desc 'Enterprise Content Governance Platform'
define 'ContentMigrator' do
  project.version = VERSION_NUMBER
  project.group = 'com.vamosa'
  manifest['Copyright'] = 'Vamosa Ltd. (C) 2003-2009'
  compile.options.target = '1.5'

  compile.with HIBERNATE, SPRING, COMMONS, LOGGING, CONTENT_PARSER, QUARTZ, J2EE_API, SCRIPTING, SOAP, JFREE_CHART, JAVASSIST, LUCENE, XALAN
  test.with XUNIT, SCALATEST
  test.using :scalatest

  # get all the important components from the Rails GUI into the staging directory
  Dir.chdir("rails") do
    puts "Changed current directory to: #{Dir.pwd}"
    warble_cfg = eval(File.open("config/warble.rb") {|f| f.read})
    Warbler::Task.new(:war, warble_cfg)
    Rake::Task['war:app'].invoke
    Rake::Task['war:public'].invoke
  end
  puts "Changed current directory to: #{Dir.pwd}"

  # package it up
  package(:war, :file =&gt; _("target/#{id}-#{VERSION_NUMBER}-#{platform}.war")).tap do |task|
    task.include 'war/*'
    task.include "src/main/resources/#{platform}.session-factory.xml", :as=&gt;'WEB-INF/session-factory.xml'
    task.include 'src/main/resources/jboss.jms-context.xml', :as=&gt;'WEB-INF/jms-context.xml'
  end
end</pre>
<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(&#8220;javax.jms:jms:jar:1.1&#8243;).from(file(&#8220;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>
<pre lang="ruby">%w(mssql mysql oracle db2).each do |platform|
  package(:war, :file =&gt; _("target/#{id}-#{VERSION_NUMBER}-#{platform}.war")).tap do |task|
    task.include 'war/*'
    task.include "src/main/resources/#{platform}.session-factory.xml", :as=&gt;'WEB-INF/session-factory.xml'
    task.include 'src/main/resources/jboss.jms-context.xml', :as=&gt;'WEB-INF/jms-context.xml'
  end
end</pre>
<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>
<div style="padding-top:5px;padding-right:0px;padding-bottom:5px;padding-left:0px;;">
											<iframe
												style="height:25px !important; border:0px solid gray !important; overflow:hidden !important; width:460px !important;" frameborder="0" scrolling="no" allowTransparency="true"
												src="http://www.linksalpha.com/social?blog=ijonas.com&link=http%3A%2F%2Fijonas.com%2Fsoftware-development%2Fruby%2F297%2F&title=Integrating+Warbler+and+Buildr+into+Scala%2C+JRuby%2C+Java+and+Rails+bliss&desc=At+Vamosa+we%27re+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%2C+whilst+still+getting+the+most+of+o&fc=333333&fs=arial&fblname=like&fblref=facebook&fbllang=en_US&fblshow=1&fbsbutton=0&fbsctr=1&fbslang=en&fbsendbutton=0&twbutton=1&twlang=en&twmention=ijonas&twrelated1=&twrelated2=&twctr=1&lnkdshow=noshow&lnkdctr=1&buzzbutton=0&buzzlang=en&buzzctr=1&diggbutton=1&diggctr=1&stblbutton=1&stblctr=1&g1button=1&g1ctr=1&g1lang=en-US">
											</iframe>
										</div>]]></content:encoded>
			<wfw:commentRss>http://ijonas.com/software-development/ruby/297/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

