Building Hudson plugins with Mirah, ROUND 1


I think this story started the day that I discovered hudson.rb. Charles sent a tweet asking for people to help him to write Hudson plugins with JRuby. The idea was there but just a few weeks ago he started the project. Hudson’s architecture was too hacky and seems that project ended with Kohsuke’s preliminary report.

Then RubyConf X arrived and I had the pleasure to meet Charles among other fellow rubists. Charlie and Tom were at the stage when they show a brief code to write JRuby extensions with Mirah, and the idea of write Hudson plugins with Mirah came to my mind, at the end, it compiles to JVM bytecode so we won’t bump into all those problems that we had with JRuby.

This was the first attempt, it didn’t compile even, but I didn’t give up, and after a couple of days of work I can say that I can write Hudson plugins with Mirah!!

All my code is still quite experimental but I’d like to share with you the problems that I found, how I’ve solved them and what’s next.

We have two mayor problems right now. First, Hudson needs to compile java code, period. It adds some hooks to the java compiler to generate binary files for the extension points. Mirah can generate that java source for us, but we’ll have to wait until this patch will be applied.

Second problem, Mirah doesn’t support java generics and Hudson uses them all around. My plan is to create a project to write wrappers to that points where a generic is required, like I’m doing with this build step descriptor and extend the mirah classes from them.

There are also other minor problems, like the fact that Mirah doesn’t have a maven plugin yet and we have to use the antrun plugin, and I’m pretty sure we’ll find more soon but I think this is a good starting point.

So, arrived at this poing the question is, where is the code??!!.

I’ve created a repository in github with a Hello world builder plugin:

And this is the Mirah code that you can find there:

The build is still quite hacky and it needs few steps:

  1. Comment the antrun plugin into the pom.xml and execute mvn compile,
    this will compile the mirah dependencies and wrappers.
  2. Uncomment the plugin and execute the same command again, this will
    generate the java source code from Mirah and will compile it.
  3. Run mvn hpi:run to load the hudson test instance.

So, what’s next? I have some ideas but any others are also welcome:

  1. Create a separate project for the wrappers for the java generics.
  2. Create a maven-mirah-plugin to be more maven friendly to generate the classes.
  3. Create a dsl to write views with erb rather than jelly.
  4. Try to Migrate my Rake and RubyMetrics plugins to mirah.

Of course any contribution is always welcome and I have a completely open commit policy, if you ask for commit privileges you get them.

Let’s see what will come in the ROUND 2!!

blog comments powered by Disqus