flow icon indicating copy to clipboard operation
flow copied to clipboard

Vaadin-gradle-plugin does not support Gradle Toolchains

Open mr-serjey opened this issue 3 months ago • 2 comments

Description of the bug

UI project utilizing vaadin-gradle-plugin fails to build on vaadinBuildFrontend task, when Gradle toolchains configured to higher version of java. e.g JAVA_HOME is java 11, toolchain version is java 17.

Failure happens since gradle compiles java using java 17, but vaadin-gradle-plugin uses java 11 to process classes.

Expected behavior

vaadin-gradle-plugin must respect gradle java toolchain configured in project and use appropriate tools for underlying steps of the build.

Minimal reproducible example

Add toolchain configuration DSL into build.gradle of UI project utilizing vaadin-gradle-plugin e.g.

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}

CLI actions:

export JAVA_HOME=<jdk11> ./gradlew build -s BUILD FAILED ... vaadinBuildFrontend failed with exception...

Versions

  • Vaadin / Flow version: 23.+, 24.+
  • Java version: 11+
  • OS version: any
  • Browser version (if applicable): n/a
  • Application Server (if applicable): n/a
  • IDE (if applicable): n/a

mr-serjey avatar May 08 '24 15:05 mr-serjey

We are not currently sure if the fact that Vaadin Gradle plugin doesn't respect it / support it is a bug or feature. Let us investigate more about Gradle Toolchain and how common it is for Gradle projects.

@mvysny do you have an idea/suggestion how to treat this issue?

mshabarov avatar May 14 '24 10:05 mshabarov

I do not know much about toolchains, but from what I read at https://docs.gradle.org/current/userguide/toolchains.html , it's a way to compile your project using a different JVM than the one running Gradle itself. In such case vaadin-gradle-plugin should then honor toolchain setting. However, that means that the class processing code (which means Flow plugin code) must run on the toolchain java rather than Gradle java, and I have no idea how that works. Needs investigating how this could be achieved, hopefully using support from Gradle itself.

mvysny avatar May 14 '24 11:05 mvysny