Over a million developers have joined DZone.

JRebel and Gradle Integration

· Java Zone

Discover how AppDynamics steps in to upgrade your performance game and prevent your enterprise from these top 10 Java performance problems, brought to you in partnership with AppDynamics.

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!

The Java Zone is brought to you in partnership with AppDynamics. AppDynamics helps you gain the fundamentals behind application performance, and implement best practices so you can proactively analyze and act on performance problems as they arise, and more specifically with your Java applications. Start a Free Trial.

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}