InfoQ

News

JRake: Build, Test, and Deploy Java applications without XML

Posted by Rob Thornton on Dec 18, 2006

Community
Java
Topics
Build systems
Tags
JRake

JRake is the latest entry in build tools for Java that is based on a scripting language. JRake leverages JRuby and the Rake build tool for Ruby to make building, running tests, and deploying web applications quick and easy.

Matt Foemmel was looking for a tool that fit two criteria: be based on a scripting language and run on the Java platform. The three tools he investigated are make, ant, and rake. Neither make nor rake run on the Java platform, and he says this about ant:

it's not based an existing scripting language. While it's true that you can drop down to Java and do complicated things by writing your own tasks, the context switch is pretty jarring. One problem is that you have the extra step of compiling your tasks before you compile your code - and therefore your build script now needs a build script. But the real issue is that Ant tasks only let you put custom logic at the task level, not at the level that actually manages the tasks. For example, if you want to define some dependencies between projects in one place, and use that to drive a bunch of build steps for each project, you're in for a tough time. It can be done (we used XSLT to generate ant scripts on one project) but it ain't pretty.

His first step was to get JRake to compile his Java code. He provides a complete "Hello World" project available at: svn://svn.foemmel.com/blog/jrake/compiling.

Step two was to get JUnit tests running from JRake. He did that and went a step further than just running JUnit tests as he wanted to avoid any unnecessary startups of the VM. To that end, he created Interactive JRake which sits in a loop prompting for targets. Once again, a sample project is available, at: svn://svn.foemmel.com/blog/jrake/testing

The third step was to provide a way to run the application. He describes his goal for this as:

Assuming our application is web-based, the obvious solution is to wrap it up in a war file and deploy it into a container. But as anyone who has worked on a large project knows, creating and deploying war files can be a painfully slow process. Our original mission was to cut as much time as possible off our edit-compile-run cycle, so this clearly isn't the right solution. (We will need to generate war files at some point, of course, for deploying into production environments, but we'll save that work for another day).

...What we really want is for Java code to work the same way that dynamically typed languages do: you change your code, hit "save", and view the results in the browser.

To meet his goal he set up a Jetty server to act as a proxy which calls out to the JRake script which results in being able to make changes in the IDE and immediately see them in the browser. The sample project is available at: svn://svn.foemmel.com/blog/jrake/running

What about Raven ? by Andres Almiray Posted Dec 18, 2006 4:12 PM
Re: What about Raven ? by James Waldrop Posted Dec 18, 2006 7:58 PM
Raven, JRake and AntBuilder by Aslak Hellesøy Posted Dec 18, 2006 8:10 PM
Need more declarative capabilities by Ilya Sterin Posted Dec 18, 2006 8:51 PM
  1. Back to top

    What about Raven ?

    Dec 18, 2006 4:12 PM by Andres Almiray

    What about Raven (raven.rubyforge.org/) ? it is already in version 1.1.2, there is even a previous article on this site about it www.infoq.com/news/2006/11/raven-build-java-wit...

  2. Back to top

    Re: What about Raven ?

    Dec 18, 2006 7:58 PM by James Waldrop

    Capistrano, too. Which admittedly isn't so much a build system as it is a deployment system, but it's probably a lot more interesting to Java devs than pure Rake.

  3. Back to top

    Raven, JRake and AntBuilder

    Dec 18, 2006 8:10 PM by Aslak Hellesøy

    I have written up a brief comparison of Raven, JRake and AntBuilder in my blog.

  4. Back to top

    Need more declarative capabilities

    Dec 18, 2006 8:51 PM by Ilya Sterin

    I can do the same with Perl or any other language. Just because there are libs to make the job easier, doesn't make it a robust tool. What is really needed, is something similar to maven or ant and is easily extended with any scripting language JRuby, Jython, etc... Hopefully JSE 6 will allow that to happen, with it's extension capabilities for DSLs.

    Either way, no one wants to script their build from scratch. Maven provides a declarative capabilities for describing your project and allows it to make assumptions. Struts provides a more flexible (though sometimes this flexibility is an overkill) environment. What is needed, is a way to say embed scripts within the build files, for things that are not naturally done in xml declarations (logic). The only big issue with ant and maven is how hard it is to perform any activities that require programming logic, loops, conditionals, etc...

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.