I am a Java Developer working in Sydney. I am eager to learn new technologies, new frameworks, new languages. Thibault has posted 8 posts at DZone. You can read more from them at their website. View Full User Profile

JRebel and Gradle Integration

07.08.2012
| 1736 views |
  • submit to reddit
I have started to use JRebel and believe me, that's a great tool! To configure it, you have to specify the absolute path of your project directories in the configuration file. When working in a team, it is always problematic to have a configuration file with absolute path in version control.

A plugin for maven exists to generate the rebel.xml files but for gradle, nope. Sadly it seems that Zeroturnaround has removed their gradle plugin from their repository.

Hopefully generating a xml file in groovy is a piece of cake. So I have done my own code to generate the rebel.xml file before building the war file.
task generateRebel << {
    def rebelFile = sourceSets.main.output.classesDir.absolutePath + '/rebel.xml'

    def srcWebApp = project.webAppDir.absolutePath
    def writer = new FileWriter(rebelFile)
    new MarkupBuilder(writer).application() {
        classpath{
            dir( name:sourceSets.main.output.classesDir.absolutePath )
        }
        web{
            link(target:'/'){
                dir(name:srcWebApp)
            }
        }
    }
}
war.dependsOn generateRebel
That's it! Your rebel.xml will be generated on the fly, you just need to activate JRebel on the server!
Published at DZone with permission of its author, Thibault Delor.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Anton Arhipov replied on Fri, 2012/07/13 - 9:25am

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.