Rebuild widgetset (to use add-on) with gradle for Spring boot vaadin app

Trying to add an add on widgetset to my vaadin application which uses spring boot to run. I’ve tried different 3rd party plugins and random scripts I found on the internet but so far nothing is working.

It seems I chose to use all the things that are not supported with convenient plugins:
Intellij Idea
Spring boot + vaadin
Gradle

Is it possible to achieve the creation of a new widgetset with this buildenvironment? Preferably with a neat Gradle task?

I finally got it to work (even though it all feels a bit hacky) with the the gradle task below.

However, to get it to work you need the default widget set xml file which is not included when using the spring boot vaadin starter lib: compile(‘com.vaadin:vaadin-spring-boot-starter:1.0.0’)

So while running the widgetset task you need the following dependency:

compile group:'com.vaadin', name:'vaadin-client-compiler', version:'7.6.8' With both dependencies I get errors when running so I turned it off again after building the widgetset. There is probably a better way to do this in gradle (I presume with custom configurations and the like) however, because I’m not going to have to rebuild often I will just use this for now.

task widgetset {

 // Monitor changes in widgetset to rebuild widgetset
    def widgetsetFile = new File('src/'+widgetsetClass.replaceAll(/\./,'/')+".gwt.xml")
    inputs.file widgetsetFile

    // Monitor changes in client side classes
    sourceSets.main.java.srcDirs.each{
        inputs.files fileTree(it.absolutePath).include('**/*/client/**/*.java')
    }

    /* Monitor changes in dependencies since upgrading a
     * dependency should also trigger a recompile of the widgetset
     */
    inputs.files configurations.compile

    // Target directory as the output
    def targetDir = new File(webAppDirName + "/VAADIN/widgetsets")
    outputs.dir targetDir

    doLast{
        // Compile
        ant.java(classname:'com.google.gwt.dev.Compiler',failOnError: 'yes', fork: 'true', maxmemory: '512m')
                {
                    classpath {
                        pathElement(path: configurations.compile.asPath)
                        pathElement(path: sourceSets.main.runtimeClasspath.asPath)
                        sourceSets.main.java.srcDirs.each{
                            pathelement(location:it.absolutePath)
                        }
                    }

                    jvmarg(value: '-Xmx1024M')
                    jvmarg(value: '-Xms512M')

                    arg(line: '-draftCompile')
                    arg(line: '-logLevel INFO')
                    arg(line: '-style PRETTY')
                    arg(line: '-localWorkers 2')
                    arg(line: '-war '+targetDir)
                    arg(line: widgetsetClass)
                }
    }
}

Hi, I’m triing to compile widgetset because new addon - FilterTable was added to application spring-boot + vaadin + gradle used in my project.
I can’t get “default widget set xml file which is not included when using the spring boot vaadin starter lib: compile(‘com.vaadin:vaadin-spring-boot-starter:1.0.0’)”, how can I achive this?

Very thanks, For this solution!

Also, in 4 line :
def widgetsetFile = new File(‘src/’+widgetsetClass.replaceAll(/./,‘/’)+“.gwt.xml”)
what widgetsetClass to specify? Of addon’s widgetset class or own’s?

I used the charts addon to generate the widgetset with these variables:

def widgetsetClass = 'com.vaadin.addon.charts.Widgetset'
def webAppDirName = "src/main/resources/"

There should be a widgetset xml file in the addon library somewhere, this is what you should target with this. So that the gradle script can find it.

Ok, Peter, i’m newbie on using vaadin addons and compile widgetset, please help me define what widgetsetClass to specify in build gradle,
if I want to add FilterTable(org.tepi.filtertable.FilterTable) addon to project and compile Widgetset. Where should I get this name?
Before it I specify com.domain.AppWidgetset.gwt.xml value to widgetsetClass and compile widgetset.
After that I run springBoot(bootRun) and i get error:
Widgetset ‘com.vaadin.DefaultWidgetset’ does not contain an implementation for org.tepi.filtertable.FilterTable. Check the connector’s @Connect mapping, the widgetset’s GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions.

I’ll really appreciate any help from you!

Looking at the source in github I found:

https://github.com/tepi/FilteringTable/blob/master/src/org/tepi/filtertable/gwt/FilterTableWidgetset.gwt.xml

so try: org.tepi.filtertable.gwt.FilterTableWidgetset

I’m not 100% sure if this will work, but it should be something like this. It’s been half a year for me too since I figured this out :wink:

FYI

I’ve just spend a few hours figuring this out and am not 100% sure yet if it works (since I still need to get an updated lisence file) but here is my current setup:

dependencies{
...
//without this javax.validation version the ant build step fails. I believe this is because gwt uses a different version and this clashes somewhere
compile group: 'javax.validation', name: 'validation-api', version: '1.0.0.GA' compile (group:'com.vaadin', name:'vaadin-client-compiler',version:"${vaadinVersion}")
}
[/code][code]
def widgetsetClass = 'com.vaadin.addon.charts.Widgetset'
def webAppDirName = "src/main/webapp/"

task widgetset{

    // Monitor changes in widgetset to rebuild widgetset
    def widgetsetFile = new File('src/'+widgetsetClass.replaceAll(/\./,'/')+".gwt.xml")
    inputs.file widgetsetFile

    // Monitor changes in client side classes
    sourceSets.main.java.srcDirs.each{
        inputs.files fileTree(it.absolutePath).include('**/*/client/**/*.java')
    }

    /* Monitor changes in dependencies since upgrading a
     * dependency should also trigger a recompile of the widgetset
     */
    inputs.files configurations.compile

    // Target directory as the output
    def targetDir = new File(webAppDirName + "/VAADIN/widgetsets")
    outputs.dir targetDir

    doLast{
        // Compile
        ant.java(classname:'com.google.gwt.dev.Compiler',failOnError: 'yes', fork: 'true', maxmemory: '2g')
                {
                    classpath {
                        pathElement(path: configurations.compile.asPath)
                        pathElement(path: sourceSets.main.runtimeClasspath.asPath)
                        sourceSets.main.java.srcDirs.each{
                            pathelement(location:it.absolutePath)
                        }
                    }

                    jvmarg(value: '-Xmx1024M')
                    jvmarg(value: '-Xms512M')
                    jvmarg(value: '-Djava.awt.headless=true')


                    arg(line: '-logLevel INFO')
                    arg(line: '-strict')
                    arg(line: '-war '+targetDir)
                    arg(line: widgetsetClass)
                }
    }
}

you may try this task:

configurations {
provided
compileWidgetset
}
task compileWidgetset << {
ant.java(classname:'com.google.gwt.dev.Compiler', failOnError: 'true', fork: 'true')
{
jvmarg(value: '-Xss1024k')
arg(line: '-logLevel INFO')
arg(line: '-war src/main/webapp/VAADIN/widgetsets')
arg(value: 'AppWidgetset')
classpath {
pathElement(location: 'src/main/resources')
pathElement(path: configurations.compile.asPath)
pathElement(path: configurations.compileWidgetset.asPath)
pathElement(path: configurations.provided.asPath)
}
}
}
war {
dependsOn compileWidgetset
archiveName = archivesBaseName + '.war'
manifest {
attributes 'Main-Class': 'com.test.main'
}
}