I am trying to compile a Hilla project with multi modules in Gradle. It works for dev with Java 17 and 21 and it works with Java 17 when I compile for production. When I try to compile it in production mode and Java 21 I get the follow error. Has anyone had this problem as well?
Task :vaadinBuildFrontend FAILED
Visiting class jdk.internal.vm.annotation.IntrinsicCandidate failed with Unsupported class file major version 65.
This might be a broken class in the project.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:vaadinBuildFrontend’.
com.vaadin.flow.server.ExecutionFailedException: Error occured during goal execution: Unsupported class file major version 65Please run Maven with the -e switch (or Gradle with the --stacktrace switch), to learn the full stack trace.
Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
I’ve found this stackoverflow post that might be related, did you try setting sourceCompatibility and targetCompatibility to 21 in your build.gradle file?
Hi @mmlopez . Thanks for the feedback! I saw that post too. I specified it in the root build.gradle and in a plugin inside buildSrc, which all modules include. That did not work. Perhaps I should specify in all individual build.gradle modules?
I was reviewing the so post that I shared with you earlier, and in there they are also mentioning about:
JAVA_HOME defaulting to the one cached in .gradle Folder in user directory even after changing the system variables to point to another JDK. Deleting the .gradle Folder fixed that issue for them, did you try this workaround?
I can share the following repository that is a working setup of a multi-module gradle project, working with both java 17 and 21 when I build for production or run via command-line or IntelliJ:
Hope it helps. Don’t hesitate to share if it doesn’t work for you.
I have tested it by upgrading Hilla to the beta version and it works to compile it. But when I run the jar it tries to compile the frontend again. I am guessing it is because it is still in Beta. I will wait until the version 24.4 is released to try again. Thanks for the feedback and fix in the next version.