Procedure to include/compile add-ons/widgesets in Vaadin Spring Boot Gradle

Hello everyone,

First of all (as it is my 1st post on the forum), I would like to thank the entire Vaadin team for providing such a well thought out framework.

Now, after too many hours failing to add the lib-gwt-imageupload add-ons to my project and find precise directions on how to compile Vaadin add-ons/widgetsets in Gradle managed projects, I would be very grateful for any advice and/or pointers in the right direction - thanks in advance.

The project is a Vaadin Spring Boot Gradle project deployed as a jar with embedded Undertow server - the IDE is Intellij Idea UE 14.1.4

Refreshing Gradle doesn’t generate any errors, but building the application gives the following:

F:\widgetest\src\main\java\com\mtvcpt\uis\components\PhotoCpnt.java
Error:(21, 23) java: cannot access com.google.gwt.user.client.ui.Widget
  class file for com.google.gwt.user.client.ui.Widget not found

The build.gradle script is as follows:

[code]
buildscript {
ext {
springBootVersion = ‘1.2.6.RELEASE’
vaadinVersion = ‘7.5.7’
}

repositories {
    mavenCentral()
    maven {
        url 'http://maven.vaadin.com/vaadin-addons'
    }
}

dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    classpath("io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE")
}

configurations {
    compile.exclude module: "spring-boot-starter-tomcat"
}

}

apply plugin: ‘java’
apply plugin: ‘eclipse’
apply plugin: ‘idea’
apply plugin: ‘spring-boot’
apply plugin: ‘io.spring.dependency-management’

jar {
baseName = ‘com.mtvcpt’
version = ‘0.0.1-SNAPSHOT’
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
maven {
url ‘http://maven.vaadin.com/vaadin-addons
}
}

dependencies {
compile(“org.springframework.boot:spring-boot-starter-actuator”)
compile(“org.springframework.boot:spring-boot-starter-data-jpa”)
compile(“org.springframework.boot:spring-boot-starter-web”)
compile(“org.springframework.boot:spring-boot-starter-undertow”)
compile(“com.vaadin:vaadin-spring-boot-starter:1.0.0”)

compile("org.vaadin.juho:lib-gwt-imageupload:0.0.3")

compile("com.h2database:h2")
testCompile("org.springframework.boot:spring-boot-starter-test")

}

dependencyManagement {
imports {
mavenBom “com.vaadin:vaadin-bom:${vaadinVersion}”
}
}

eclipse {
classpath {
containers.remove(‘org.eclipse.jdt.launching.JRE_CONTAINER’)
containers ‘org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8’
}
}

task wrapper(type: Wrapper) {
gradleVersion = ‘2.6’
}
[/code]The failing Class (which extends as CustomComponent) is:

[code]
package com.mtvcpt.uis.components;

import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.ui.Button;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Panel;
import org.vaadin.juho.imageupload.client.ImageUpload;

import java.io.Serializable;

/**
*
*/
@SpringComponent
public class PhotoCpnt extends CustomComponent implements Serializable {

final ImageUpload fileUpload = new ImageUpload();

public PhotoCpnt() {
    final Button TakePhoto = new Button(null, e -> {
        fileUpload.click(); [color=#B22222]


<— Line giving the error

[/color]
});

    Panel panel = new Panel();
    panel.setSizeFull();
    setCompositionRoot(panel);
}

}
[/code]Thanks again in advance.

Me again, after trying a few other things to no avail, I decided to try V-Leaflet in a simpler test and see what happens. This time no build error but I get the following message in the UI:

Widgetset 'com.vaadin.DefaultWidgetSet' does not contain implementation
for org.vaadin.addon.leaflet.LMap. Check its component connector's @Connect mapping,
widgetsets 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.

Recommended add-on’s maven install parameters which I have applied to gradle script:

<repository>
   <id>vaadin-addons</id>
   <url>http://maven.vaadin.com/vaadin-addons</url>
</repository>

<dependency>
   <groupId>org.vaadin.addon</groupId>
   <artifactId>v-leaflet</artifactId>
   <version>1.0.0-b3</version>
</dependency>

build.gradle (excerpt):

repositories {
    mavenCentral()
    maven {
        url 'http://maven.vaadin.com/vaadin-addons'
    }
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-actuator")
    compile("org.springframework.boot:spring-boot-starter-undertow")
    compile("com.vaadin:vaadin-spring-boot-starter:1.0.0")

    compile("org.vaadin.addon:v-leaflet:1.0.0-b3")

    testCompile("org.springframework.boot:spring-boot-starter-test")
}

Lmap component initialisation source:

[code]
@SpringComponent
public class MyMapCpnt() extends CustomComponent implements Serializable{

public MyMapCpnt() {
    LMap leafletMap = new LMap();
    leafletMap.setCenter(60.4525, 22.301);
    leafletMap.setZoomLevel(15);

    Panel panel = new Panel();
    panel.setSizeFull();
    panel.setContent(leafletMap);

    setCompositionRoot(panel);
}

}
[/code]Obviously I am overlooking something which is likely quite simple but can’t see what it is… I would therefore be very grateful if anyone could guide me with the settings needed by the buidl.gradle script of a Vaadin Spring Boot Gradle project (deployed as a jar with embedded server) so add-ons can be recognised and its widgetsets compiled automatically.

Thanks again in advance.

I would recommend having a look at the Spring Boot Groovy Vaadin Starter for a working example of using Gradle with Vaadin and Spring Boot.

Spring Boot Groovy Vaadin Starter
https://github.com/christoph-frick/springboot-groovy-vaadin-starter

Hello John, thank you for this, I see that we have the same sources hehe :wink:
Indeed I actually looked into it the other day (as well as again yesterday) but without success. I’ll continue digging until I find the magic formula… thanks again. :slight_smile: