Class BuildFrontendUtil

java.lang.Object
com.vaadin.flow.plugin.base.BuildFrontendUtil

public class BuildFrontendUtil extends Object
Util class provides all methods a Plugin will need.
  • Method Details

    • getClassFinder

      public static com.vaadin.flow.server.frontend.scanner.ClassFinder getClassFinder(List<String> classpathElements)
      creates a ClassFinder from a List of classpathElements.
      Parameters:
      classpathElements - the list of classpath elements
      Returns:
      the ClassFinder that uses the classpathElements
    • getTokenFile

      public static File getTokenFile(PluginAdapterBase adapter)
      Location of the Token File.
      Parameters:
      adapter - - the PluginAdapterBase.
      Returns:
      File the Token File
    • prepareFrontend

      public static void prepareFrontend(PluginAdapterBase adapter) throws IOException, com.vaadin.flow.server.frontend.ExecutionFailedException, URISyntaxException
      Prepares the Frontend
      Parameters:
      adapter - - the PluginAdapterBase.
      Throws:
      IOException - - Could not forceMkdir(adapter.generatedFolder());
      com.vaadin.flow.server.frontend.ExecutionFailedException - - While NodeTasks.execute()
      URISyntaxException - - Could not build an URI from nodeDownloadRoot().
    • propagateBuildInfo

      public static File propagateBuildInfo(PluginAdapterBase adapter)
      Propagates the BuildInfo.
      Parameters:
      adapter - - the PluginAdapterBase.
      Returns:
      the Token File.
    • runNodeUpdater

      public static void runNodeUpdater(PluginAdapterBuild adapter, com.vaadin.flow.server.frontend.scanner.FrontendDependenciesScanner frontendDependencies) throws com.vaadin.flow.server.frontend.ExecutionFailedException, URISyntaxException
      runs the node-Updater.
      Parameters:
      adapter - - the PluginAdapterBase.
      frontendDependencies - Frontend dependencies scanner to use. If not set, one will be initialized by Options class later.
      Throws:
      com.vaadin.flow.server.frontend.ExecutionFailedException - - a ExecutionFailedException.
      URISyntaxException - - - Could not build an URI from nodeDownloadRoot().
    • runDevBuildNodeUpdater

      public static void runDevBuildNodeUpdater(PluginAdapterBuild adapter) throws com.vaadin.flow.server.frontend.ExecutionFailedException, URISyntaxException, IOException
      Run a dev-bundle build.
      Parameters:
      adapter - - the PluginAdapterBase.
      Throws:
      com.vaadin.flow.server.frontend.ExecutionFailedException - - a ExecutionFailedException.
      URISyntaxException - - - Could not build an URI from nodeDownloadRoot().
      IOException
    • getFrontendDirectory

      public static File getFrontendDirectory(PluginAdapterBase adapter)
      Get the legacy frontend folder if available and new folder doesn't exist.
      Parameters:
      adapter - PluginAdapterBase
      Returns:
      correct folder or legacy folder if not user defined
    • getGeneratedFrontendDirectory

      public static File getGeneratedFrontendDirectory(PluginAdapterBase adapter)
      The generated folder should be under frontend folder and will be moved to the legacy package if not changed by the user.
      Parameters:
      adapter - PluginAdapterBase
      Returns:
      correct generated folder as child to frontend
    • runFrontendBuild

      public static void runFrontendBuild(PluginAdapterBase adapter) throws TimeoutException, URISyntaxException
      Execute the frontend build with the wanted build system.
      Parameters:
      adapter - - the PluginAdapterBase.
      Throws:
      TimeoutException - - while running build system
      URISyntaxException - - while parsing nodeDownloadRoot()) to URI
    • runVite

      public static void runVite(PluginAdapterBase adapter, com.vaadin.flow.server.frontend.FrontendTools frontendTools) throws TimeoutException
      Runs the Vite build
      Parameters:
      adapter - - the PluginAdapterBase.
      frontendTools - - frontend tools access object
      Throws:
      TimeoutException - - while running vite
    • validateLicenses

      public static boolean validateLicenses(PluginAdapterBuild adapter, com.vaadin.flow.server.frontend.scanner.FrontendDependenciesScanner frontendDependencies)
      Validate pro component licenses.

      When PluginAdapterBuild.optimizeBundle() is false the bytecode scanner is disabled and every commercial component present on the classpath is assumed to be used, regardless of whether the application actually references it. In that case the thrown LicenseException uses a dedicated message that explains the classpath-level detection and suggests concrete workarounds (re-enable bundle optimization, switch to com.vaadin:vaadin-core, or exclude com.vaadin:vaadin from a transitive dependency).

      Parameters:
      adapter - the PluginAdapterBuild
      frontendDependencies - frontend dependencies scanner
      Returns:
      true if license validation is required because of the presence of commercial components, otherwise false.
      Throws:
      com.vaadin.pro.licensechecker.MissingLicenseKeyException - if commercial components are used in a commercial banner-enabled build and no license key is present
      com.vaadin.pro.licensechecker.LicenseException - if commercial components are used without a license and commercial banner is not enabled
    • validateLicenses

      @Deprecated(since="25.2", forRemoval=true) public static boolean validateLicenses(PluginAdapterBase adapter, com.vaadin.flow.server.frontend.scanner.FrontendDependenciesScanner frontendDependencies)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Validate pro component licenses.
      Parameters:
      adapter - the PluginAdapterBase
      frontendDependencies - frontend dependencies scanner
      Returns:
      true if license validation is required because of the presence of commercial components, otherwise false.
      Throws:
      com.vaadin.pro.licensechecker.MissingLicenseKeyException - if commercial components are used in a commercial banner-enabled build and no license key is present
      com.vaadin.pro.licensechecker.LicenseException - if commercial components are used without a license and commercial banner is not enabled
    • updateBuildFile

      @Deprecated(since="24.9", forRemoval=true) public static void updateBuildFile(PluginAdapterBuild adapter, boolean licenseRequired)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Updates the build info after the bundle has been built by build-frontend.

      Removes the abstract folder paths as they should not be used for prebuilt bundles and ensures production mode is set to true.

      Parameters:
      adapter - - the PluginAdapterBase.
      licenseRequired - true if a license was required for the production build.
    • updateBuildFile

      public static void updateBuildFile(PluginAdapterBuild adapter, boolean licenseRequired, boolean needsCommercialBanner)
      Updates the build info after the bundle has been built by build-frontend.

      Removes the abstract folder paths as they should not be used for prebuilt bundles and ensures production mode is set to true.

      Parameters:
      adapter - - the PluginAdapterBase.
      licenseRequired - true if a license was required for the production build.
      needsCommercialBanner - true if a commercial banner should be applied to the application at runtime.
    • removeBuildFile

      public static void removeBuildFile(PluginAdapterBuild adapter) throws IOException
      Delete the build token file. This is used with dev-bundle build as token file should never be added to the package.
      Parameters:
      adapter - used plugin adapter implementation
      Throws:
      IOException