Class BundleValidationUtil

java.lang.Object
com.vaadin.flow.server.frontend.BundleValidationUtil

public final class BundleValidationUtil extends Object
Bundle handling methods.

For internal use only. May be renamed or removed in a future release.

Since:
24.1
  • Constructor Details

    • BundleValidationUtil

      public BundleValidationUtil()
  • Method Details

    • needsBuild

      public static boolean needsBuild(Options options, FrontendDependenciesScanner frontendDependencies, ClassFinder finder, Mode mode)
      Checks if an application needs a new frontend bundle.
      Parameters:
      options - Flow plugin options
      frontendDependencies - frontend dependencies scanner to lookup for frontend imports
      finder - class finder to obtain classes and resources from class-path
      mode - Vaadin application mode
      Returns:
      true if a new frontend bundle is needed, false otherwise
    • hasJarBundle

      public static boolean hasJarBundle(String jarPath, ClassFinder finder)
      Check if jar bundle exists on given path.
      Parameters:
      jarPath - JAR path where bunlde to check is located
      Returns:
      true if bundle stats.json is found
    • getPackageJson

      public static elemental.json.JsonObject getPackageJson(Options options, FrontendDependenciesScanner frontendDependencies, ClassFinder finder)
      Get the package.json file from disk if available else generate in memory.

      For the loaded file update versions as per in memory to get correct application versions.

      Parameters:
      options - the task options
      frontendDependencies - frontend dependency scanner
      finder - classfinder
      Returns:
      package.json content as JsonObject
    • getDefaultPackageJson

      public static elemental.json.JsonObject getDefaultPackageJson(Options options, FrontendDependenciesScanner frontendDependencies, ClassFinder finder, elemental.json.JsonObject packageJson)
    • hashAndBundleModulesEqual

      public static boolean hashAndBundleModulesEqual(elemental.json.JsonObject statsJson, elemental.json.JsonObject packageJson, Map<String,String> npmPackages)
      Verify that package hash versions are equal and that all project npmPackages are in bundle.
      Parameters:
      statsJson - devBundle statsJson
      packageJson - packageJson
      npmPackages - npm packages map
      Returns:
      true if up to date
    • exportedWebComponents

      public static boolean exportedWebComponents(elemental.json.JsonObject statsJson, ClassFinder finder)
    • frontendImportsFound

      public static boolean frontendImportsFound(elemental.json.JsonObject statsJson, Options options, ClassFinder finder, FrontendDependenciesScanner frontendDependencies) throws IOException
      Throws:
      IOException
    • calculateHash

      public static String calculateHash(String fileContent)
    • getStatsHash

      public static String getStatsHash(elemental.json.JsonObject statsJson)
    • getPackageJsonHash

      public static String getPackageJsonHash(elemental.json.JsonObject packageJson)
    • logChangedFiles

      public static void logChangedFiles(List<String> frontendFiles, String message)
    • getProdBundleResource

      public static URL getProdBundleResource(String filename, ClassFinder finder)
    • needsBundleBuild

      public static boolean needsBundleBuild(File resourceOutputFolder)
      Checks if a new production bundle is needed by restoring re-bundle checker result flag from a temporal file.
      Parameters:
      resourceOutputFolder - output directory for generated non-served resources
      Returns:
      true if a new bundle is needed, false otherwise