I am currently investigating using JRuby on Rails with Maven 3, and whilst I am still far away from getting a proper running application, I think it is worth summarizing what I have found so far.
JRuby Maven Plugins
An excellent starting point is the set of plugins called JRuby Maven plugins (not to be confused with jruby-maven-plugin to write JRuby mojos, rather than using Jelly). The information is a bit sparse and outdated, but after while tinkering with them, I found them pretty easy to use. To use them, you must first have a JRuby on Rails project:
(Documentation says it is -Drails.version=3.0.3, but it is incorrect). The jruby-maven-archetype currently is number 21, so you can enter its number at the prompt, as well as its current version number (0.23.0), and then the groupId, the artifactId of your app (here myapp, like the rails app), the version, and the package name.
Once the application is set up, you should be able to run it with the following command:
sebastien@greystones:/tmp$ cd myapp
sebastien@greystones:/tmp$ mvn rails3:server
bundle is a great addition to rails 3; unfortunately, it is not available from maven commands provided by JRuby maven plugins yet. That’s why I wrote the following addition to these plugins, bundle-maven-plugin. It is still ongoing work, so it is still a bit rough, but it should do the trick for bundleinstall, update, package, exec and config commands.
Making a war
This is the next step in the process… and I haven’t had the chance to get to it yet. However, it looks like warbler is the tool for this task, so I’m guessing this will be another post.
One extra thing to mention (as this has caused me some issues) is that when using rvm, you should avoid installing jruby as the first ruby, as it looks like it tries to use it to compile the following ones — causing troubles to install 1.9.2-head. If you have installed jruby as the first ruby, you can delete it with rvm remove, then install MRI, or ree, and only then install jruby.
(It is very likely that this is caused by the fact my “system” ruby was actually a ruby I had compiled myself…)
I have been looking into licensing problems lately, in particular regarding the GPL — I guess its copyleft approach is what makes it so confusing. There is a lot of information on the GNU website, enough to get you started. But what I can’t get my head around is how to go about forking a GPL project, especially with the advent of github-like websites where projects and their forks1 can now live happy lives on their own: do you have to rename the project (or is the name itself is covered by the GPL and you change it as you want, as long as you maintain the copyright/licensing notices — but then isn’t the name part of the licensing notice)? Do you add your copyright to the files you modified, or to all of them (heck, just renaming the project is enough to modify all files)? In a word, forking a GPL project is not a trivial thing to do.
As there are bucket loads of open-source projects out there, I thought that all these legal matters had already been tackled by other programmers (presumably chatting with their solicitors), and that asking these questions would quickly and easily find an answer. Nah. Don’t bother programmers with this legal nonsense. Let’s paddle with leaves down an ecstatic line of light, and bring Mono to Ubuntu, and see how big a bang that can do.
It is then interesting to have a look at what other projects have done… And clearly, programmers have no clue when it comes to licensing and copyright issues, and dos and don’ts, which is very worrying for the companies or the open-source project they work for. The first project I looked at, the forked project had altered all the copyright notices from the original files, and as far as I understand the whole thing, this is in breach of the GPL (I could be wrong, mind you, but I haven’t been able to get a proper answer yet).
So the standard answer is “talk to your solicitor.” But how many developers have done so, that we can’t bloody find answers to common legal issues? If they haven’t, how many projects out there are actually… not legit? What are the risks in turn for companies and OSS projects that use or derive work from these projects? I mean, what is to stop them from bringing some (GPL) third party library into the codebase, unbeknownst to the legal team, and then put the whole company into jeopardy? Easily done. Especially if said developers would rather put their head into the sand to avoid seeing this.
IMO, that is extremely worrying, and even more worrying that programmers actually think this is not their problem. And disasters like this don’t really surprise me anymore…
 Obviously, not all git forks are forks in the traditional sense, but some are. Some github projects are also “forks” from sourceforge projects. The good thing about the git “fork” approach is that it removes the stigmas associated with forking, which, for some reason, was regarded as a bad thing — and it probably was, given that the most notable ones arose mostly from bitterness.
Having a scripting language in the toolbox is invaluable; and if the scripting language happens to be Ruby, you’re armed with the Swiss knife that’ll turn you into McGyver.
As a Java developer, you need to know more than Java to be able to work efficiently:
you need to know an editor like Emacs or Vi,
you need to know a fair bit of Linux/Unix commands, and of shell script,
you need to know a scripting language.
Why the scripting language? Because there are lots of stuff you need to do on a daily basis, and Java is far too big a tool to do them (understand, far too slow to code, far too slow to compile, far too slow to deploy, etc.):
generated scripts via regexp (like creating SQL delete from SQL insert),
Ant (or even more pathological, Maven) uses XML to alleviate some of these issues, but XML is just not “appropriate” for these tasks: the build scripts size explodes and are very hard to maintain, unless you resort to some macrodef trickery that are just symptomatic of the fact that you actually really need a proper scripting language…
The two recent examples I have is actually producing reports in a quick fashion. The first example is actually something I wrote, as I was asked to create a list of users of an application by querying the LDAP directory. On the very first day of work in my very first company, I worked with LDAP, and have been ever since, so doing an ldapsearch for this kind of query was easy stuff; formatting the report is always a bit more tricky, because you have to sed the hell out of the output, and let’s face it, I don’t speak sed very well. The Java/JNDI option is far far too heavy for a simple report (and it does make you look a bit stupid if it takes you like half a day to produce a report listing all your users…), so the scripting option is ideal.
Having never used the ruby-ldap extension, I was a bit worried that its installation would be hard, especially behind an overzealous proxy, but it went very smoothly on Cygwin — here are the command in the unpacked archive:
All put together in 5 min. The cool thing about this was that the people who were requesting this report asked for different versions with different attributes, and the turnaround was almost instantaneous!
The second example is a script I came across whilst browsing snipplr, which solves problems I have seen solved with XML/XSL in the past: extracting the substantifique moëlle of an XML report to produce a summary on a CI report. Using Nokogiri, it just becomes trivial to parse an XML document (here a JUnit XML log) to produce a report. Think of all the applications! Creating code coverage reports, creating dashboards, providing querying features to end users via DSLs (piece of cake with ruby)…
Ruby (and more specifically JRuby) has really become for me one of the most useful tools, and it has that extra-special feature that it makes me feel like McGyver whenever I come up with a solution to a problem within minutes in a very minimal amount of code. And Holy Richard Dean Anderson knows that if the following were to happen, life would be even happier:
Rakify all Java projects, and ditch Ant (Maven),
Create a Ruby implementation of Emacs, where you can write Ruby scripts rather than ELisp,
Write a Ruby version of eclipsemonkey (I know the project is actually parked, but I just cannot. understand. why, the JS version being already so absolutely essential) — Aptana may have that in their drawers, actually, I never really checked.