Vaadin 14 + Gradle (migration from Vaadin 13)

Hi,

I’m in the process of migrating a Vaadin application from V13 to V14 and the project uses Gradle as the build system. However, at the moment it is not using the [vaadin-gradle-plugin]
(https://github.com/vaadin/vaadin-gradle-plugin). Instead, the Vaadin dependencies are managed manually. I came across the section in the [v14-migration-guide]
(https://vaadin.com/docs/v14/flow/v14-migration/v14-migration-guide.html) that mentions the Vaadin Maven plugin and was wondering how to do this in/with Gradle:

<build>
    <plugins>
        ...
        <plugin>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-maven-plugin</artifactId>
            <version>${vaadin.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>prepare-frontend</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Does someone know how to approach this with Gradle? At the moment it just seems to be working without this part, but I guess there is a reason for it being mentioned in the migration guide.

Additionally, is this already or will this (in the final release) be handled by the Vaadin Gradle plugin? Any information on this?

Hi! With Vaadin 14 in the compatibility mode, the client-side stuff was downloaded by Gradle (the -webjar.jars), and so no further compilation steps were necessary. However, with the new NPM mode the client-side is compiled/packaged with webpack, and so a specialized plugin is necessary.

There is an alpha release of the Vaadin Gradle Plugin - please feel free to give it a go and let us know whether it works for you :slight_smile: Please find the example project here: https://github.com/vaadin/base-starter-gradle and the plugin itself here: https://github.com/vaadin/vaadin-gradle-plugin

Hi Martin! Thanks for your feedback. Actually, a few days after posting this I wanted to give the vaadin-gradle-plugin a try. With my setup, though, I’m currently not able to make it work.

At the moment I’m using Java 13 in conjunction with Gradle 4.10.3. As Gradle 5.6.4 is recommended in the vaadin-gralde-plugin documentation, I upgraded to that version but it seems that something has changed between these two versions as I’m no longer able to build my project under Gradle 5.6.4. (I cannot recall whether the vaadin-gralde-plugin was active or not, though.) This might be related: [https://github.com/gradle/gradle/issues/10785]
(https://github.com/gradle/gradle/issues/10785)

I just noticed that the plugin has been updated recently. I think I will give it another try in the next days. I’ll keep you posted here.

So here’s an update:

I gave the Vaadin Gradle Plugin another try (v0.5.0). Because I use Java 13 I had to update to Gradle 6.x. Now with Gradle 6.1.1 I’m able to successfully open and build the project. But there’s still a problem.

Since I use Guice as a DI framework ([Guice Vaadin]
(https://github.com/berndhopp/guice/tree/vaadin14) makes it really easy to use Guice with Vaadin), I have an additional Gradle source set configured to keep the main sources separated from the Guice sources. This causes a circular dependency between Gradle tasks when executing the vaadinBuildFrontend task. So at the moment I would only be able to use the plugin for development but not for building for production, which is a bit unfortunate. I already created an issue for that on Github where I also provide a project with an exemplary configuration: [https://github.com/vaadin/vaadin-gradle-plugin/issues/42]
(https://github.com/vaadin/vaadin-gradle-plugin/issues/42). I’m not quite sure if this is something that can be “fixed” by adjusting the plugin’s behavior. Maybe someone here has an idea for a workaround?

Another update for anyone curious:

The issue was fixed about 3 weeks ago. With the new Version of the Vaadin Gralde Plugin (v0.6.0) it’s now working.