Class VaadinPlugin

java.lang.Object
com.vaadin.quarkus.deployment.vaadinplugin.VaadinPlugin

public final class VaadinPlugin extends Object
Implementation of the Vaadin plugin.

This class is a porting of Vaadin Maven prepare-frontend and build-frontend mojos.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    buildFrontend(BiConsumer<String,byte[]> emitter)
    Builds the frontend bundle.
    void
    Cleans up generated frontend files if the corresponding configuration setting is enabled.
    of(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.
    void
    Checks that node and npm tools are installed and creates or updates `package.json` and the frontend build tool configuration files.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.BuildException
      Checks 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.BuildException
      Builds the frontend bundle.

      It performs the following actions when creating a package:
      • Update Constants.PACKAGE_JSON file with the NpmPackage annotations 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_NAME file imports with the JsModule Theme and JavaScript annotations defined in the classpath,
      • Update FrontendUtils.VITE_CONFIG file.
      Parameters:
      emitter - generated files emitter.
      Throws:
      io.quarkus.builder.BuildException - if any error occurs.
    • 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.