Package org.webjars

Class WebJarExtractor

java.lang.Object
org.webjars.WebJarExtractor

public class WebJarExtractor extends Object
Utility for extracting WebJars onto the filesystem. The extractor also recognises the node_modules convention used by WebJars. node_modules are a special place within a WebJar that contain the assets required in an environment conforming to the Node API for require.
  • Field Details

  • Constructor Details

    • WebJarExtractor

      public WebJarExtractor()
    • WebJarExtractor

      public WebJarExtractor(@Nonnull ClassLoader classLoader)
  • Method Details

    • extractAllWebJarsTo

      public void extractAllWebJarsTo(@Nullable File to) throws IOException
      Extract all WebJars.
      Parameters:
      to - The directory to extract to
      Throws:
      IOException - There was a problem extracting the WebJars
    • extractWebJarTo

      public void extractWebJarTo(@Nullable String name, @Nullable File to) throws IOException
      Extract the given WebJar to the given location. The WebJar will be extracted, without its version in the path, to the given directory.
      Parameters:
      name - The name of the WebJar to extract.
      to - The location to extract it to. All WebJars will be merged into this location.
      Throws:
      IOException - There was a problem extracting the WebJars
    • extractAllNodeModulesTo

      public void extractAllNodeModulesTo(@Nullable File to) throws IOException
      Extract the node_modules of all WebJars and merge them into the same folder.
      Parameters:
      to - The location to extract it to. All WebJars will be merged into this location.
      Throws:
      IOException - There was a problem extracting the WebJars
    • extractAllBowerComponentsTo

      public void extractAllBowerComponentsTo(@Nullable File to) throws IOException
      Extract the bower_components of all WebJars and merge them into the same folder.
      Parameters:
      to - The location to extract it to. All WebJars will be merged into this location.
      Throws:
      IOException - There was a problem extracting the WebJars
    • getJsonModuleId

      @Nullable protected static String getJsonModuleId(@Nonnull String packageJson) throws IOException
      Throws:
      IOException