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 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, ExecutionFailedException, URISyntaxException
      Prepares the Frontend
      Parameters:
      adapter - - the PluginAdapterBase.
      Throws:
      IOException - - Could not forceMkdir(adapter.generatedFolder());
      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) throws ExecutionFailedException, URISyntaxException
      runs the node-Updater.
      Parameters:
      adapter - - the PluginAdapterBase.
      Throws:
      ExecutionFailedException - - a ExecutionFailedException.
      URISyntaxException - - - Could not build an URI from nodeDownloadRoot().
    • runDevBuildNodeUpdater

      public static void runDevBuildNodeUpdater(PluginAdapterBuild adapter) throws ExecutionFailedException, URISyntaxException, IOException
      Run a dev-bundle build.
      Parameters:
      adapter - - the PluginAdapterBase.
      Throws:
      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, FrontendTools frontendTools) throws TimeoutException
      Runs the Vite build
      Parameters:
      adapter - - the PluginAdapterBase.
      frontendTools - - frontend tools access object
      Throws:
      TimeoutException - - while running vite
    • validateProductionLicense

      public static void validateProductionLicense()
      Validates the Flow license for a production build.

      The check runs in strict offline mode, so it fails if the license server cannot be reached and no valid offline or server license key is available. If no license key is found, it fails immediately instead of opening a browser to download a key, because production builds usually run on CI servers.

      Build tools must call this for every production build, also when the frontend bundle is not built because the default bundle or an existing bundle is used.

      Throws:
      com.vaadin.pro.licensechecker.MissingLicenseKeyException - if no license key is found
      com.vaadin.pro.licensechecker.LicenseException - if no valid license is available
    • validateLicenses

      public static boolean validateLicenses(PluginAdapterBase adapter)
      Validate pro component licenses.
      Parameters:
      adapter - the PluginAdapterBase
      Returns:
      true if license validation is required because of the presence of commercial components, otherwise false.
    • updateBuildFile

      @Deprecated public static void updateBuildFile(PluginAdapterBuild adapter)
      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.
    • updateBuildFile

      public static void updateBuildFile(PluginAdapterBuild adapter, boolean licenseRequired)
      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.
    • 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