This project demos the possibility of having Vaadin project in npm+webpack mode using Gradle. Please see the Starting a Vaadin project using Gradle for the documentation.
Prerequisites:
- Java 21 or higher
- Git
- (Optionally): Intellij Ultimate
- (Optionally): Node.js and npm, if you have JavaScript/TypeScript customisations in your project.
- You can either let the Vaadin Gradle plugin to install
Node.jsandnpm/pnpmfor you automatically, or you can install it to your OS: - Windows: node.js Download site - use the .msi 64-bit installer
- Linux:
sudo apt install npm
- You can either let the Vaadin Gradle plugin to install
- The v25 branch (the default one) contains the example app for Vaadin latest version
- See other branches for other Vaadin versions.
Run the following command in this repo:
./gradlew clean appRunNow you can open the http://localhost:8080 with your browser.
In order to run integration tests you need to add the it gradle parameter:
./gradlew integrationTest -PitThen you can check results in the build/reports/tests/integrationTest/index.html file
Simply run the following command in this repo:
./gradlew clean buildIf you want to run tests at the same time:
./gradlew clean build -PitThat will build this app in production mode as a WAR archive; please find the
WAR file in build/libs/base-starter-gradle.war. You can run the WAR file
by using Jetty Runner:
cd build/libs/
wget https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-runner/11.0.15/jetty-runner-11.0.15.jar
java -jar jetty-runner-11.0.15.jar base-starter-gradle.warNow you can open the http://localhost:8080 with your browser.
Usually the CI images will not have node.js+npm available. Luckily Vaadin will download nodejs and npm/pnpm automatically, there is nothing you need to do.
To build your app for production in CI, just run:
./gradlew clean buildTo build and run ITs at the same time run:
./gradlew clean build -Pit -Dcom.vaadin.testbench.Parameters.headless=true- Download and unpack the newest Tomcat 10.
- Open this project in Intellij Ultimate.
- Click "Edit Launch Configurations", click "Add New Configuration" (the upper-left button which looks like a plus sign
+), then select Tomcat Server, Local. In the Server tab, the Application Server will be missing, click the "Configure" button and point Intellij to the Tomcat directory.- Still in the launch configuration, in the "Deployment" tab, click the upper-left + button, select "Artifact" and select
base-starter-gradle.war (exploded). - Still in the launch configuration, name the configuration "Tomcat" and click the "Ok" button.
- Still in the launch configuration, in the "Deployment" tab, click the upper-left + button, select "Artifact" and select
Now make sure Vaadin is configured to be run in development mode - run:
./gradlew clean vaadinPrepareFrontend- Select the "Tomcat" launch configuration and hit Debug (the green bug button).
If Tomcat fails to start with Error during artifact deployment. See server log for details., please:
- Go and vote for IDEA-178450.
- Then, kill Tomcat by pressing the red square button.
- Then, open the launch configuration, "Deployment", remove the (exploded) war, click
+and selectbase-starter-gradle.war.
Make sure Vaadin is configured to be run in development mode - run:
./gradlew clean vaadinPrepareFrontendIn Intellij, open the right Gradle tab, then go into Tasks / gretty, right-click the appRun task and select Debug. Gretty will now start in debug mode, and will auto-deploy any changed resource or class.
There are a couple of downsides:
- Even if started in Debug mode, debugging your app won't work.
- Pressing the red square "Stop" button will not kill the server and will leave it running. Instead, you have to focus the console and press any key - that will kill Gretty cleanly.
- If Gretty says "App already running", there is something running on port 8080. See above on how to kill Gretty cleanly.