java.lang.Object
com.github.blutorange.maven.plugin.closurecompiler.common.ProcessFilesTask
All Implemented Interfaces:
Callable<List<ProcessingResult>>
Direct Known Subclasses:
ProcessJSFilesTask

public abstract class ProcessFilesTask extends Object implements Callable<List<ProcessingResult>>
Abstract class for merging and compressing a files list.
  • Field Details

    • mojoMeta

      protected final MojoMetadata mojoMeta
    • closureConfig

      protected final ClosureConfig closureConfig
    • files

      protected final List<File> files
    • includesEmpty

      protected final boolean includesEmpty
    • outputFilenameInterpolator

      protected final com.github.blutorange.maven.plugin.closurecompiler.common.FilenameInterpolator outputFilenameInterpolator
    • processConfig

      protected final FileProcessConfig processConfig
    • sourceDir

      protected final File sourceDir
    • targetDir

      protected final File targetDir
  • Constructor Details

    • ProcessFilesTask

      public ProcessFilesTask(MojoMetadata mojoMeta, FileProcessConfig processConfig, FileSpecifier fileSpecifier, ClosureConfig closureConfig) throws IOException
      Task constructor.
      Parameters:
      mojoMeta - Base mojo data.
      processConfig - Configuration for this file task.
      fileSpecifier - Details about the input / output files.
      closureConfig - Google closure configuration
      Throws:
      IOException - When an input file could not be read or an output file could not be written.
  • Method Details

    • call

      public List<ProcessingResult> call() throws IOException, org.apache.maven.plugin.MojoFailureException
      Method executed by the thread.
      Specified by:
      call in interface Callable<List<ProcessingResult>>
      Throws:
      IOException - When an input file could not be read or an output file could not be written.
      org.apache.maven.plugin.MojoFailureException - When the merge or minify steps fail
    • removeMessages

      protected final void removeMessages(Collection<File> files)
    • logCompressionGains

      protected final void logCompressionGains(List<File> srcFiles, String minified)
      Logs compression gains.
      Parameters:
      srcFiles - list of input files to compress
      minified - output file resulting from the minify step
    • mkDir

      protected final void mkDir(File directory)
      Creates the given directory (and parents) and informs the build context.
      Parameters:
      directory - Path of the directory to create.
    • copy

      protected final ProcessingResult copy(File sourceFile, File targetFile) throws IOException
      Copies sourceFile to targetFile, making sure to inform the build context of the change.
      Parameters:
      sourceFile - The source file to copy.
      targetFile - The target file to which to copy the source file.
      Returns:
      true if execution was performed, false if it was skipped (because files did not change).
      Throws:
      IOException - When an input file could not be read or an output file could not be written.
    • merge

      protected final ProcessingResult merge(File mergedFile) throws IOException
      Merges a list of source files. Create missing parent directories if needed.
      Parameters:
      mergedFile - output file resulting from the merged step
      Throws:
      IOException - when the merge step fails
    • haveFilesChanged

      protected final boolean haveFilesChanged(Collection<File> sourceFiles, Collection<File> outputFiles)
      Checks whether any change was made to the source / output file pairs. If not, then we can skip the execution of the current bundle.
      Parameters:
      sourceFiles - Source files to check.
      outputFiles - Output files corresponding to the source files, in that order. Must have the same size as the source files list.
      Returns:
      Whether any change was made to the source / output file pairs