InfoQ

News

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

Posted by Rob Thornton on Dec 18, 2006 01:00 PM

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

5 comments

Reply

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
Build a Application by Jackie Van Posted Nov 18, 2008 8:34 AM
  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...

  5. Back to top

    Build a Application

    Nov 18, 2008 8:34 AM by Jackie Van

    Wholesale lingerie directly from China?
    As a famous brand and specialized manufacturer of sexy clothing in China. We supply the international market with fashionable sexy lingerie and sexy costume since 2002. With advanced technology,all our products are of high quality. Now we have clients all around the world. Lingerie Wholesale and OEM are welcomed!
    As a Lingerie Manufacturer, Charmingirl has standard workshop and production line, professional designers and experienced workers.
    We do Wholesale Underwear,
    Lingerie Wholesale, including corset and bustier,
    Sexy Lingerie Wholesale, including bikini, underwear
    Lingerie Wholesale, and Babydolls, Sexy Lingerie Wholesale, and
    Sexy Lingerie Wholesale including sleepwear,clubwear.
    Lingerie Wholesale from China: Lingerie China, you will find the
    Leather Lingerie and PVC Lingerie, also you can buy
    Christmas Costume and Xmas Lingerie
    for your Christmas Lingerie Christmas day.
    Our Wholesale center: Sexy Lingerie Wholesale can do Lingerie Wholesale online.
    Halloween Costume,
    also wholesale Adult Costume with fashion Babydoll Babydoll, and bra and panties Bra and Panties, Sexy Uniform Sexy Uniform is also our major products.
    we have strong ability on production, research and technology, advanced facilities that is imported fromGermany and Japan, now our monthly output is 100000 pcs.

Exclusive Content

Dan Farino About MySpace’s Architecture

Dan Farino talks about the system architecture and the challenges faced when building a very large online community. Dan explains how a .NET product scales on hundreds of servers.

The Maxine VM

Bernd Mathiske discusses Maxine VM, Java compatibility, swapping major VM components, research areas, Object handling, code examples, optimizing compiler, snippets, bytecode generation, JNI and JIT.

Joe Armstrong About Erlang

Joe Armstrong speaks on various aspects of the Erlang language, presenting its roots, how it compares with other languages and why it has become popular these days.

The Limits of Code Optimization: a new Singleton Pattern Implementation

The java double-check singleton pattern is not thread safe and can’t be fixed. In this article, Dr. Alexey Yakubovich provides an implementation of the Singleton pattern that he claims is thread-safe.

Pressure and Performance – The CTO's Dilemma

Diana and Jim talk about patterns observed in CTOs' activity. CTOs emerge as real people caring for other people in their organization, and are put under a lot of pressure and constraints.

Biztalk Services in the Cloud

Cloud computing feels like a tomorrow technology. Simon Thurman shows how developers can use Biztalk to create an Internet Service Bus which can be deployed locally or in the cloud.

Java FX Technology Preview

InfoQ takes a look at the JavaFX preview build and talks to Sun Staff Engineer Joshua Marinacci about the upcoming version 1 release expected this autumn.

Jeff Sutherland: Reaching Hyper-Productivity with Outsourced Development Teams

Jeff Sutherland, co-creator of Scrum, and Guido Schoonheim, CTO of Xebia, present an actual case of reaching hyper-productivity with a large distributed team using XP and Scrum.