Class VaadinPlugin
java.lang.Object
com.vaadin.quarkus.deployment.vaadinplugin.VaadinPlugin
Implementation of the Vaadin plugin.
This class is a porting of Vaadin Maven prepare-frontend and build-frontend mojos.
-
Method Summary
Modifier and TypeMethodDescriptionvoidbuildFrontend(BiConsumer<String, byte[]> emitter) Builds the frontend bundle.voidclean()Cleans up generated frontend files if the corresponding configuration setting is enabled.static VaadinPluginof(VaadinBuildTimeConfig vaadinConfig, io.quarkus.bootstrap.model.ApplicationModel applicationModel, Path outputTarget) Creates a new instance of the VaadinPlugin based on the provided configuration and application model.voidChecks that node and npm tools are installed and creates or updates `package.json` and the frontend build tool configuration files.
-
Method Details
-
of
public static VaadinPlugin of(VaadinBuildTimeConfig vaadinConfig, io.quarkus.bootstrap.model.ApplicationModel applicationModel, Path outputTarget) throws io.quarkus.builder.BuildException Creates a new instance of the VaadinPlugin based on the provided configuration and application model. If necessary, it attempts to load workspace information for the plugin.- Parameters:
vaadinConfig- the Vaadin build time configuration.applicationModel- the application model representing the current application.outputTarget- the target directory for output operations.- Returns:
- an instance of VaadinPlugin initialized with the given parameters.
- Throws:
io.quarkus.builder.BuildException- if workspace information cannot be loaded or an error occurs during the process.
-
prepareFrontend
public void prepareFrontend() throws io.quarkus.builder.BuildExceptionChecks that node and npm tools are installed and creates or updates `package.json` and the frontend build tool configuration files.
Copies frontend resources available inside `.jar` dependencies to `node_modules` when building a jar package.- Throws:
io.quarkus.builder.BuildException- if any error occurs.
-
buildFrontend
public void buildFrontend(BiConsumer<String, byte[]> emitter) throws io.quarkus.builder.BuildExceptionBuilds the frontend bundle.
It performs the following actions when creating a package:- Update
Constants.PACKAGE_JSONfile with theNpmPackageannotations defined in the classpath, - Copy resource files used by flow from `.jar` files to the `node_modules` folder
- Install dependencies by running
npm install - Update the
FrontendUtils.IMPORTS_NAMEfile imports with theJsModuleThemeandJavaScriptannotations defined in the classpath, - Update
FrontendUtils.VITE_CONFIGfile.
- Parameters:
emitter- generated files emitter.- Throws:
io.quarkus.builder.BuildException- if any error occurs.
- Update
-
clean
public void clean()Cleans up generated frontend files if the corresponding configuration setting is enabled. The process involves creating a new cleaning task with specific options derived from the plugin adapter's configuration and executing it. If an error occurs during the execution of the clean task, it is logged for debugging purposes.The cleanup operation ensures the following: - Deletes the generated frontend files in the `node_modules` folder. - Utilizes the directory configurations such as frontend directory, npm folder, and generated TypeScript folder to locate the files. - Makes use of the `TaskCleanFrontendFiles` for cleanup operations.
-