Need Gradle sample to build widgetset and theme

I have a deployment chain setup with Jenkins performing a war build using Gradle. I am attempting to add widgetset compilation to that build script and have found this forum discussion:!/thread/3626284

Which I’m guessing nearly addresses the issue, but leaves off the build the gwt configuration. Is there a full sample available of a gradle build of a Vaadin app which incorporates widgetset and theme compilation?

Are you using gradle-vaadin-plugin? If not, I think you should. It has pretty good documentation too:

I’m not presently using that plugin, and I’m not sure it would help. To me the documentation makes it look like the kind of think you have to use from project inception, which was over a year ago. Our push works like this:

  1. We created a project over a year ago in Eclipse. And since then it has lives in SVN where the team edits it.
  2. After a commit, Jenkins extracts the project from SVN and builds it using gradle, storing the new war in Nexus.
  3. I visit the QA box and manually (with a script) deploy the new war to that box.
  4. We test the app on the QA box weekly.
  5. When all problems are addressed, I update the build number in the file, and commit that update. That enables arelease build.
  6. I visit Jenkins and direct it to build a release, which it stores in Nexus.
  7. I visit staging and deploy the war for an “in-situ” test as staging it as close to a mirror as prod as can be achieved.
  8. Staging is smoke tested and when all is well, I deploy to prod.

So, gradle is already installed on our build box, and I suspect there is something missing to “tie the bow”. Below is the build.gradle I pieced together from the forum discussion I referenced above:

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

sourceCompatibility = 1.8
targetCompatibility = 1.8

group = 'com.ourcompany'
version = appVersion

publishing {
publications {
snapshot(MavenPublication) {
artifactId = artifactName
version meVersion+'-SNAPSHOT'
from components.web
release(MavenPublication) {
artifactId = artifactName
version meVersion
from components.web
repositories {
maven {
credentials {
username 'deployment-user'
password 'deployment-password'
name "Release"
url "http://our-repository-machine/nexus/content/repositories/releases"
maven {
credentials {
username 'deployment-user'
password 'deployment-password'
name "Snapshot"
url "http://our-repository-machine/nexus/content/repositories/snapshots"

repositories {
maven { url "" }
maven { url "" }

sourceSets {
main {
java {
srcDir 'src'
srcDir 'common'
srcDir 'desktop'
srcDir 'mobile'
resources { srcDir 'resources' }

configurations.all {
resolutionStrategy.force 'org.apache.deltaspike.core:deltaspike-core-api:1.6.1'
resolutionStrategy.force 'org.apache.deltaspike.core:deltaspike-core-impl:1.6.1'
resolutionStrategy.force 'com.vaadin:vaadin-client-compiled:' + vaadinVersion

dependencies {
providedCompile group: 'javax', name: 'javaee-api', version: '7.0'
providedCompile 'org.eclipse.persistence:eclipselink:2.6.3'

compile "org.apache.commons:commons-email:${commonsEmailVersion}"
compile "com.vaadin:vaadin-server:${vaadinVersion}"
compile "com.vaadin:vaadin-client-compiled:${vaadinVersion}"
compile "com.vaadin:vaadin-client-compiler:${vaadinVersion}"
compile "com.vaadin:vaadin-themes:${vaadinVersion}"
compile "com.vaadin:vaadin-theme-compiler:${vaadinVersion}"
compile "com.vaadin:vaadin-push:${vaadinVersion}"
compile "com.vaadin.addon:vaadin-context-menu:${vaadinContextMenu}"
compile "com.vaadin:vaadin-cdi:${vaadinCdi}"
compile "com.wcs.wcslib:wcslib-vaadin-widget-multifileupload:${vaadinMultiFile}"
compile "org.vaadin.addons:exporter:${exporterVersion}"
compile "javax.validation:validation-api:1.0.0.GA"

compile "org.olap4j:olap4j:${olapVersion}"
compile "com.lowagie:itext:${itextVersion}"
compile "net.sf.jasperreports:jasperreports:${jasperVersion}"
compile "org.apache.httpcomponents:httpmime:${httpmimeVersion}"
compile "${guavaVersion}"
compile "org.apache.solr:solr-solrj:${solrVersion}"

compile "org.apache.shiro:shiro-core:${shiroVersion}"
compile "org.apache.shiro:shiro-web:${shiroVersion}"

compile "commons-logging:commons-logging:${commonsLogging}"

def widgetsetClass = 'com.millereads.blacknblue.widgetset.OurWidgetset'
def webAppDirName = 'WebContent'

task cleanWidgetset(type: Delete) {
delete webAppDirName+'/VAADIN/widgetsets'

task compileWidgetset(type: JavaExec, dependsOn: cleanWidgetset) {
main = ''
classpath sourceSets.main.resources.srcDirs
classpath configurations.compile
classpath configurations.gwt
jvmArgs '-Xss1024k'
args '-logLevel'
args 'INFO'
args '-war'
args webAppDirName+'/VAADIN/widgetsets'
args '-deploy'
args webAppDirName+'/WEB-INF/deploy'

war {
baseName = artifactName
webAppDirName = 'WebContent'
archiveName = baseName + '.war'
dependsOn compileWidgetset

As you can see from the build.gradle file, at the very least, I do not know configurations.gwt


You are right in that the Gradle Vaadin Plugin will help you a lot when you are starting a new project with its project initialization methods. But, that has just been added for convienience, the real task of the plugin is actually to correctly build the widgetset and theme and ensure you have the right dependencies to do so. So I think it would help you out signigicantly in your task.

To include the plugin into your build you just need to append the following to the top of the build.gradle file:

plugins { id 'fi.jasoft.plugin.vaadin.groovy' version '1.1.6' } That is all that is needed.

The plugin comes with a
task that is doing exactly the same as you are doing in your
task except it also handles some corner cases. The plugin also binds to the
task just as you do so I think it should work out of the box for you and should should be able to remove a lot of code in the build.gradle file by just including the plugin.