Run Errai/GWT with Gradle

Hi there,

In the last days I tried to get an App with the Errai Framework running. The hard part was, to get it running with Gradle support instead of Maven.

Therefore I decided to create a small howto, to get other people also able to run Errai with Gradle.

At first I’d like to thank Max Barkley, member of the JBoss Team, who gave me the last important hints. And Peter, a co-worker in my Company who helped me to fix the Gradle script.


To get the App running, you will need:

  • Gradle 1.7, I think it will also work with earlier Versions, but I did it with 1.7
  • Enterprise Application Server

Furthermore you will need the following Dependencies in your Project:

  • org.jboss.errai:errai-javaee-all:2.4.0.Final, which is the current Version the Errai-Framework (28.09.2013)
  •, which contains the GWT compiler

You can find the Source Code here.

Lets get it running

I started with searching for a compile script for GWT, because Errai basically just extends GWT, and found a Skript where I had to do some minor modifications.

task compileGwt (dependsOn: classes, type: JavaExec) { 
buildDir = "${project.buildDir}/gwt"
extraDir = "${project.buildDir}/extra" inputs.source 
inputs.dir sourceSets.main.output.resourcesDir
outputs.dir buildDir // Workaround for incremental build (GRADLE-1483)
outputs.upToDateSpec = new org.gradle.api.specs.AndSpec() doFirst { 
main = '' classpath { [, // Java source 
 sourceSets.main.output.resourcesDir, // Generated 
 resources sourceSets.main.output.classesDir, // Generated 
 classes sourceSets.main.compileClasspath, // Deps ]
args = [ '', // Your GWT module 
 '-war', buildDir, '-logLevel', 'INFO', '-localWorkers', 
 '2', '-compileReport', '-extra', extraDir ]
 maxHeapSize = '256M' 

Furthermore we have to add a few lines for the war plugin, so that it recognizes that there are new Folders:
war.dependsOn compileGwt war { from "$buildDir/gwt" from "$buildDir/extra" }.
Thats it, with running the Task compileGWT gradle will compile all needed files.

To let the app run you just have to deploy it on your Application Server. You also can use the Eclipse GWT plugin. You just have to use the „Run on external Server“ dialogue. This will generate you some unwanted Files in your webapp folder, which you have to clean up afterwards manually.

Known Issues

I wasn’t able to get the App running with Errai version 2.3.2.Final. The app directly crashed during startup. So I decided to use version 2.4.0.Final, after that the AS, I used JBoss 7, threw an exception which you basically can ignore:

Available types: [jarfile, jarUrl, directory, vfsfile, vfszip, org.jboss.errai.common.metadata.WarUrlType@1e8608b4, *.jnilib, *.zip, *.pom] Do you need to add app server specific support to your deployment? (For example, errai-jboss-as-support for AS7) at org.jboss.errai.reflections.vfs.Vfs.fromURL( [reflections-2.4.0.Final.jar:2.4.0.Final]

The JBoss Team is already aware of that.