Example of GWT compilation and WAR packaging for a Vaadin project

hi! I have tried using Vaadin Gradle plugin, but the latest versions (0.9, 0.9.1) don’t recompile GWT widgetset for some reason and the older versions had other issues. so I switched back to calling GWT Compiler directly (not clear what the value of that plugin vs. direct GWT Compiler call is anyway).

so, now the widgetset compilation works fine, but vaadin-server and some other jars are missing in the WAR file.

so… can someone please post a sample build.gradle file for a Vaadin project that calls GWT Compiler directly without using Vaadin Gradle Plugin?

here’s my build.gradle file for “webui” module. again, it builds the widgetset fine, but it does NOT include vaadin-server and some other jars in the war file. some online posts suggest this maybe due to the fact that “providedCompile” dependency prevents some transitive jars from being added to the WAR.

in other words, let’s say you have:

providedCompile "com.vaadin:vaadin-client:$vaadinVersion"
    compile "com.vaadin:vaadin-server:$vaadinVersion"
  • here vaadin-server will NOT be included in the WAR because vaadin-client has dependency on “vaadin-client” (as you can see http://search.maven.org/#artifactdetails|com.vaadin|vaadin-client|7.3.2|jar ). I can fix this issue by declaring vaadin-client dependency as “Compile” instead of “providedCompile”, but then the WAR file has a bunch of vaadin jars which are actually not needed there.
apply plugin: 'war'
  dependencies {
    compile "com.vaadin:vaadin-server:$vaadinVersion"
    compile "com.vaadin:vaadin-client-compiled:$vaadinVersion"
    compile "com.vaadin:vaadin-themes:$vaadinVersion"
    compile 'org.vaadin.addons:googleanalyticstracker:2.0.0'
      compile libraries.slf4j
    providedCompile libraries.servletAPI
    providedCompile "com.vaadin:vaadin-client:$vaadinVersion"
    providedCompile "com.vaadin:vaadin-client-compiler:$vaadinVersion"
      compile project(":webshared")
      compile project( -- skipped... many other modules of the same project -- )
      testCompile project(":test-utilities")
  ext {
    webAppDirName = "src/main/webapp"
    gwtBuildDirInWebRoot = 'VAADIN/widgetsets'
    gwtBuildDir = webAppDirName + '/' + gwtBuildDirInWebRoot
    widgetsetClass = 'com.taskadapter.webui.widgetset.Vaadin1Widgetset'
  war {
    // Exclude unneccessery GWT Compiler artifacts
    exclude "**/gwt-unitCache/**"
  task widgetset << {
    // Create widgetset directory (if needed)
    def created = (new File(gwtBuildDir)).mkdirs()
      // Compile
    ant.java(classname: 'com.google.gwt.dev.Compiler', failOnError: 'yes',
maxmemory: '1000m', fork: 'true')
                classpath {
                    pathElement(path: configurations.compile.asPath)
                    pathElement(path: sourceSets.main.runtimeClasspath.asPath)
                    sourceSets.main.java.srcDirs.each {
                        pathelement(location: it.absolutePath)
                  arg(line: '-war ' + gwtBuildDir)
                arg(line: '-logLevel INFO')
                arg(line: '-style OBF')
                arg(line: '-localWorkers 2')
                arg(line: widgetsetClass)
              jvmarg(value: '-Djava.awt.headless=true')
              jvmarg(value: '-XX:MaxPermSize=256M')
              jvmarg(value: '-Xmx500M')
    // Require widgetset compilation before WAR is built
war.dependsOn widgetset

I could filter out the unneeded Jars from the WAR file in

war {
    // Exclude unneccessery GWT Compiler artifacts
    exclude "**/gwt-unitCache/**"
exclude some vaadin jars here ........
  • but this seems like a hack.