Class HtmlCompressorMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
com.tunyk.mvn.plugins.htmlcompressor.HtmlCompressorMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="html", defaultPhase=COMPILE, requiresProject=false, threadSafe=true) public class HtmlCompressorMojo extends org.apache.maven.plugin.AbstractMojo
Compress HTML files.
  • Field Details

    • htmlCompressionStatistics

      @Parameter(property="htmlcompressor.htmlCompressionStatistics", defaultValue="${project.build.directory}/htmlcompressor/html-compression-statistics.txt") private String htmlCompressionStatistics
      file where statistics of html compression is stored.
    • fileExt

      @Deprecated @Parameter(property="htmlcompressor.fileExt") private String[] fileExt
      Deprecated.
      use fileExtensions
      file types to be processed.
    • fileExtensions

      @Parameter(property="htmlcompressor.fileExtensions") private String[] fileExtensions
      File extensions to be processed.
    • enabled

      @Parameter(property="htmlcompressor.enabled", defaultValue="true") private boolean enabled
      if false all compression is off (default is true).
    • skip

      @Parameter(defaultValue="false", alias="skip", property="skip") private boolean skip
      Skip run of plugin.
    • removeComments

      @Parameter(property="htmlcompressor.removeComments", defaultValue="true") private boolean removeComments
      if false keeps HTML comments (default is true).
    • removeMultiSpaces

      @Parameter(property="htmlcompressor.removeMultiSpaces", defaultValue="true") private boolean removeMultiSpaces
      if false keeps multiple whitespace characters (default is true).
    • removeIntertagSpaces

      @Parameter(property="htmlcompressor.removeIntertagSpaces", defaultValue="false") private boolean removeIntertagSpaces
      removes iter-tag whitespace characters.
    • removeQuotes

      @Parameter(property="htmlcompressor.removeQuotes", defaultValue="false") private boolean removeQuotes
      removes unnecessary tag attribute quotes.
    • simpleDoctype

      @Parameter(property="htmlcompressor.simpleDoctype", defaultValue="false") private boolean simpleDoctype
      simplify existing doctype.
    • removeScriptAttributes

      @Parameter(property="htmlcompressor.removeScriptAttributes", defaultValue="false") private boolean removeScriptAttributes
      remove optional attributes from script tags.
    • removeStyleAttributes

      @Parameter(property="htmlcompressor.removeStyleAttributes", defaultValue="false") private boolean removeStyleAttributes
      remove optional attributes from style tags.
    • removeLinkAttributes

      @Parameter(property="htmlcompressor.removeLinkAttributes", defaultValue="false") private boolean removeLinkAttributes
      remove optional attributes from link tags.
    • removeFormAttributes

      @Parameter(property="htmlcompressor.removeFormAttributes", defaultValue="false") private boolean removeFormAttributes
      remove optional attributes from form tags.
    • removeInputAttributes

      @Parameter(property="htmlcompressor.removeInputAttributes", defaultValue="false") private boolean removeInputAttributes
      remove optional attributes from input tags.
    • simpleBooleanAttributes

      @Parameter(property="htmlcompressor.simpleBooleanAttributes", defaultValue="false") private boolean simpleBooleanAttributes
      remove values from boolean tag attributes.
    • removeJavaScriptProtocol

      @Parameter(property="htmlcompressor.removeJavaScriptProtocol", defaultValue="false") private boolean removeJavaScriptProtocol
      remove "javascript:" from inline event handlers.
    • removeHttpProtocol

      @Parameter(property="htmlcompressor.removeHttpProtocol", defaultValue="false") private boolean removeHttpProtocol
      replace "http://" with "//" inside tag attributes.
    • removeHttpsProtocol

      @Parameter(property="htmlcompressor.removeHttpsProtocol", defaultValue="false") private boolean removeHttpsProtocol
      replace "https://" with "//" inside tag attributes.
    • compressCss

      @Parameter(property="htmlcompressor.compressCss", defaultValue="false") private boolean compressCss
      compress inline css.
    • preserveLineBreaks

      @Parameter(property="htmlcompressor.preserveLineBreaks", defaultValue="false") private boolean preserveLineBreaks
      preserves original line breaks.
    • yuiCssLineBreak

      @Parameter(property="htmlcompressor.yuiCssLineBreak", defaultValue="-1") private int yuiCssLineBreak
      --line-break param for Yahoo YUI Compressor.
    • cssCompressor

      @Parameter(property="htmlcompressor.cssCompressor", defaultValue="") private com.googlecode.htmlcompressor.compressor.Compressor cssCompressor
      css compressor.
    • compressJavaScript

      @Parameter(property="htmlcompressor.compressJavaScript", defaultValue="false") private boolean compressJavaScript
      compress inline javascript.
    • jsCompressor

      @Parameter(property="htmlcompressor.jsCompressor", defaultValue="yui") private String jsCompressor
      javascript compression: "yui" or "closure".
    • javaScriptCompressor

      @Parameter(property="htmlcompressor.javaScriptCompressor", defaultValue="") private com.googlecode.htmlcompressor.compressor.Compressor javaScriptCompressor
      javascript compression.
    • yuiJsNoMunge

      @Parameter(property="htmlcompressor.yuiJsNoMunge", defaultValue="false") private boolean yuiJsNoMunge
      --nomunge param for Yahoo YUI Compressor.
    • yuiJsPreserveAllSemiColons

      @Parameter(property="htmlcompressor.yuiJsPreserveAllSemiColons", defaultValue="false") private boolean yuiJsPreserveAllSemiColons
      --preserve-semi param for Yahoo YUI Compressor.
    • yuiJsLineBreak

      @Parameter(property="htmlcompressor.yuiJsLineBreak", defaultValue="-1") private int yuiJsLineBreak
      --line-break param for Yahoo YUI Compressor.
    • closureOptLevel

      @Parameter(property="htmlcompressor.closureOptLevel", defaultValue="simple") private String closureOptLevel
      closureOptLevel = "simple", "advanced" or "whitespace".
    • yuiJsDisableOptimizations

      @Parameter(property="htmlcompressor.yuiJsDisableOptimizations", defaultValue="false") private boolean yuiJsDisableOptimizations
      --disable-optimizations param for Yahoo YUI Compressor.
    • predefinedPreservePatterns

      @Parameter(property="htmlcompressor.predefinedPreservePatterns") private String[] predefinedPreservePatterns
      predefined patterns for most often used custom preservation rules: PHP_TAG_PATTERN and SERVER_SCRIPT_TAG_PATTERN.
    • preservePatterns

      @Parameter(property="htmlcompressor.preservePatterns") private String[] preservePatterns
      preserve patterns.
    • preservePatternFiles

      @Parameter(property="htmlcompressor.preservePatternFiles") private File[] preservePatternFiles
      list of files containing preserve patterns.
    • generateStatistics

      @Parameter(property="htmlcompressor.generateStatistics", defaultValue="true") private boolean generateStatistics
      HTML compression statistics.
    • srcFolder

      @Parameter(property="htmlcompressor.srcFolder", defaultValue="${basedir}/src/main/resources") private String srcFolder
      source folder where html files are located.
    • targetFolder

      @Parameter(property="htmlcompressor.targetFolder", defaultValue="${project.build.directory}/classes") private String targetFolder
      target folder where compressed html files will be placed.
    • javascriptHtmlSprite

      @Parameter(property="htmlcompressor.javascriptHtmlSprite", defaultValue="true") private boolean javascriptHtmlSprite
      Create javascript file which includes all compressed html files as json object. If set to true then javascriptHtmlSpriteIntegrationFile param is required, otherwise it will throw exception.
    • javascriptHtmlSpriteIntegrationFile

      @Parameter(property="htmlcompressor.javascriptHtmlSpriteIntegrationFile", defaultValue="${basedir}/src/main/resources/html/integration.js") private String javascriptHtmlSpriteIntegrationFile
      JavaScript sprite integration file (first occurrence of "%s" will be substituted by json with all compressed html strings).
    • javascriptHtmlSpriteTargetFile

      @Parameter(property="htmlcompressor.javascriptHtmlSpriteTargetFile", defaultValue="${project.build.directory}/htmlcompressor/html/integration.js") private String javascriptHtmlSpriteTargetFile
      The target JavaScript sprite file with compressed html files as json object.
    • encoding

      @Parameter(property="htmlcompressor.encoding", defaultValue="UTF-8") private String encoding
      Charset encoding for files to read and create.
    • closureCustomExternsOnly

      @Parameter(property="htmlcompressor.closureCustomExternsOnly", defaultValue="false") private boolean closureCustomExternsOnly
      Disable default built-in closure externs.
    • closureExterns

      @Parameter(property="htmlcompressor.closureExterns") private String[] closureExterns
      Sets custom closure externs file list.
  • Constructor Details

    • HtmlCompressorMojo

      public HtmlCompressorMojo()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • getHtmlCompressionStatistics

      public String getHtmlCompressionStatistics()
      Gets the html compression statistics.
      Returns:
      the html compression statistics
    • setHtmlCompressionStatistics

      public void setHtmlCompressionStatistics(String htmlCompressionStatistics)
      Sets the html compression statistics.
      Parameters:
      htmlCompressionStatistics - the new html compression statistics
    • getFileExt

      @Deprecated public String[] getFileExt()
      Deprecated.
      use getFileExtensions
      Gets the file ext.
      Returns:
      the file ext
    • setFileExt

      @Deprecated public void setFileExt(String[] fileExt)
      Deprecated.
      use setFileExtensions
      Sets the file ext.
      Parameters:
      fileExt - the new file ext
    • getFileExtensions

      public String[] getFileExtensions()
      Gets the file ext.
      Returns:
      the file extensions
    • setFileExtensions

      public void setFileExtensions(String[] fileExtensions)
      Sets the file ext.
      Parameters:
      fileExtensions - the new file ext
    • getEnabled

      public Boolean getEnabled()
      Gets the enabled.
      Returns:
      the enabled
    • setEnabled

      public void setEnabled(Boolean enabled)
      Sets the enabled.
      Parameters:
      enabled - the new enabled
    • getRemoveComments

      public Boolean getRemoveComments()
      Gets the removes the comments.
      Returns:
      the removes the comments
    • setRemoveComments

      public void setRemoveComments(Boolean removeComments)
      Sets the removes the comments.
      Parameters:
      removeComments - the new removes the comments
    • getRemoveMultiSpaces

      public Boolean getRemoveMultiSpaces()
      Gets the removes the multi spaces.
      Returns:
      the removes the multi spaces
    • setRemoveMultiSpaces

      public void setRemoveMultiSpaces(Boolean removeMultiSpaces)
      Sets the removes the multi spaces.
      Parameters:
      removeMultiSpaces - the new removes the multi spaces
    • getRemoveIntertagSpaces

      public Boolean getRemoveIntertagSpaces()
      Gets the removes the intertag spaces.
      Returns:
      the removes the intertag spaces
    • setRemoveIntertagSpaces

      public void setRemoveIntertagSpaces(Boolean removeIntertagSpaces)
      Sets the removes the intertag spaces.
      Parameters:
      removeIntertagSpaces - the new removes the intertag spaces
    • getRemoveQuotes

      public Boolean getRemoveQuotes()
      Gets the removes the quotes.
      Returns:
      the removes the quotes
    • setRemoveQuotes

      public void setRemoveQuotes(Boolean removeQuotes)
      Sets the removes the quotes.
      Parameters:
      removeQuotes - the new removes the quotes
    • getSimpleDoctype

      public Boolean getSimpleDoctype()
      Gets the simple doctype.
      Returns:
      the simple doctype
    • setSimpleDoctype

      public void setSimpleDoctype(Boolean simpleDoctype)
      Sets the simple doctype.
      Parameters:
      simpleDoctype - the new simple doctype
    • getRemoveScriptAttributes

      public Boolean getRemoveScriptAttributes()
      Gets the removes the script attributes.
      Returns:
      the removes the script attributes
    • setRemoveScriptAttributes

      public void setRemoveScriptAttributes(Boolean removeScriptAttributes)
      Sets the removes the script attributes.
      Parameters:
      removeScriptAttributes - the new removes the script attributes
    • getRemoveStyleAttributes

      public Boolean getRemoveStyleAttributes()
      Gets the removes the style attributes.
      Returns:
      the removes the style attributes
    • setRemoveStyleAttributes

      public void setRemoveStyleAttributes(Boolean removeStyleAttributes)
      Sets the removes the style attributes.
      Parameters:
      removeStyleAttributes - the new removes the style attributes
    • getRemoveLinkAttributes

      public Boolean getRemoveLinkAttributes()
      Gets the removes the link attributes.
      Returns:
      the removes the link attributes
    • setRemoveLinkAttributes

      public void setRemoveLinkAttributes(Boolean removeLinkAttributes)
      Sets the removes the link attributes.
      Parameters:
      removeLinkAttributes - the new removes the link attributes
    • getRemoveFormAttributes

      public Boolean getRemoveFormAttributes()
      Gets the removes the form attributes.
      Returns:
      the removes the form attributes
    • setRemoveFormAttributes

      public void setRemoveFormAttributes(Boolean removeFormAttributes)
      Sets the removes the form attributes.
      Parameters:
      removeFormAttributes - the new removes the form attributes
    • getRemoveInputAttributes

      public Boolean getRemoveInputAttributes()
      Gets the removes the input attributes.
      Returns:
      the removes the input attributes
    • setRemoveInputAttributes

      public void setRemoveInputAttributes(Boolean removeInputAttributes)
      Sets the removes the input attributes.
      Parameters:
      removeInputAttributes - the new removes the input attributes
    • getSimpleBooleanAttributes

      public Boolean getSimpleBooleanAttributes()
      Gets the simple boolean attributes.
      Returns:
      the simple boolean attributes
    • setSimpleBooleanAttributes

      public void setSimpleBooleanAttributes(Boolean simpleBooleanAttributes)
      Sets the simple boolean attributes.
      Parameters:
      simpleBooleanAttributes - the new simple boolean attributes
    • getRemoveJavaScriptProtocol

      public Boolean getRemoveJavaScriptProtocol()
      Gets the removes the java script protocol.
      Returns:
      the removes the java script protocol
    • setRemoveJavaScriptProtocol

      public void setRemoveJavaScriptProtocol(Boolean removeJavaScriptProtocol)
      Sets the removes the java script protocol.
      Parameters:
      removeJavaScriptProtocol - the new removes the java script protocol
    • getRemoveHttpProtocol

      public Boolean getRemoveHttpProtocol()
      Gets the removes the http protocol.
      Returns:
      the removes the http protocol
    • setRemoveHttpProtocol

      public void setRemoveHttpProtocol(Boolean removeHttpProtocol)
      Sets the removes the http protocol.
      Parameters:
      removeHttpProtocol - the new removes the http protocol
    • getRemoveHttpsProtocol

      public Boolean getRemoveHttpsProtocol()
      Gets the removes the https protocol.
      Returns:
      the removes the https protocol
    • setRemoveHttpsProtocol

      public void setRemoveHttpsProtocol(Boolean removeHttpsProtocol)
      Sets the removes the https protocol.
      Parameters:
      removeHttpsProtocol - the new removes the https protocol
    • getCompressCss

      public Boolean getCompressCss()
      Gets the compress css.
      Returns:
      the compress css
    • setCompressCss

      public void setCompressCss(Boolean compressCss)
      Sets the compress css.
      Parameters:
      compressCss - the new compress css
    • getPreserveLineBreaks

      public Boolean getPreserveLineBreaks()
      Gets the preserve line breaks.
      Returns:
      the preserve line breaks
    • setPreserveLineBreaks

      public void setPreserveLineBreaks(Boolean preserveLineBreaks)
      Sets the preserve line breaks.
      Parameters:
      preserveLineBreaks - the new preserve line breaks
    • getYuiCssLineBreak

      public Integer getYuiCssLineBreak()
      Gets the yui css line break.
      Returns:
      the yui css line break
    • setYuiCssLineBreak

      public void setYuiCssLineBreak(Integer yuiCssLineBreak)
      Sets the yui css line break.
      Parameters:
      yuiCssLineBreak - the new yui css line break
    • getCompressJavaScript

      public Boolean getCompressJavaScript()
      Gets the compress java script.
      Returns:
      the compress java script
    • setCompressJavaScript

      public void setCompressJavaScript(Boolean compressJavaScript)
      Sets the compress java script.
      Parameters:
      compressJavaScript - the new compress java script
    • getJsCompressor

      public String getJsCompressor()
      Gets the js compressor.
      Returns:
      the js compressor
    • setJsCompressor

      public void setJsCompressor(String jsCompressor)
      Sets the js compressor.
      Parameters:
      jsCompressor - the new js compressor
    • getYuiJsNoMunge

      public Boolean getYuiJsNoMunge()
      Gets the yui js no munge.
      Returns:
      the yui js no munge
    • setYuiJsNoMunge

      public void setYuiJsNoMunge(Boolean yuiJsNoMunge)
      Sets the yui js no munge.
      Parameters:
      yuiJsNoMunge - the new yui js no munge
    • getYuiJsPreserveAllSemiColons

      public Boolean getYuiJsPreserveAllSemiColons()
      Gets the yui js preserve all semi colons.
      Returns:
      the yui js preserve all semi colons
    • setYuiJsPreserveAllSemiColons

      public void setYuiJsPreserveAllSemiColons(Boolean yuiJsPreserveAllSemiColons)
      Sets the yui js preserve all semi colons.
      Parameters:
      yuiJsPreserveAllSemiColons - the new yui js preserve all semi colons
    • getYuiJsLineBreak

      public Integer getYuiJsLineBreak()
      Gets the yui js line break.
      Returns:
      the yui js line break
    • setYuiJsLineBreak

      public void setYuiJsLineBreak(Integer yuiJsLineBreak)
      Sets the yui js line break.
      Parameters:
      yuiJsLineBreak - the new yui js line break
    • getClosureOptLevel

      public String getClosureOptLevel()
      Gets the closure opt level.
      Returns:
      the closure opt level
    • setClosureOptLevel

      public void setClosureOptLevel(String closureOptLevel)
      Sets the closure opt level.
      Parameters:
      closureOptLevel - the new closure opt level
    • getYuiJsDisableOptimizations

      public Boolean getYuiJsDisableOptimizations()
      Gets the yui js disable optimizations.
      Returns:
      the yui js disable optimizations
    • setYuiJsDisableOptimizations

      public void setYuiJsDisableOptimizations(Boolean yuiJsDisableOptimizations)
      Sets the yui js disable optimizations.
      Parameters:
      yuiJsDisableOptimizations - the new yui js disable optimizations
    • getPredefinedPreservePatterns

      public String[] getPredefinedPreservePatterns()
      Gets the predefined preserve patterns.
      Returns:
      the predefined preserve patterns
    • setPredefinedPreservePatterns

      public void setPredefinedPreservePatterns(String[] predefinedPreservePatterns)
      Sets the predefined preserve patterns.
      Parameters:
      predefinedPreservePatterns - the new predefined preserve patterns
    • getPreservePatterns

      public String[] getPreservePatterns()
      Gets the preserve patterns.
      Returns:
      the preserve patterns
    • setPreservePatterns

      public void setPreservePatterns(String[] preservePatterns)
      Sets the preserve patterns.
      Parameters:
      preservePatterns - the new preserve patterns
    • getPreservePatternFiles

      public File[] getPreservePatternFiles()
      Gets the preserve pattern files.
      Returns:
      the preserve pattern files
    • setPreservePatternFiles

      public void setPreservePatternFiles(File[] preservePatternFiles)
      Sets the preserve pattern files.
      Parameters:
      preservePatternFiles - the new preserve pattern files
    • getGenerateStatistics

      public Boolean getGenerateStatistics()
      Gets the generate statistics.
      Returns:
      the generate statistics
    • setGenerateStatistics

      public void setGenerateStatistics(Boolean generateStatistics)
      Sets the generate statistics.
      Parameters:
      generateStatistics - the new generate statistics
    • getSrcFolder

      public String getSrcFolder()
      Gets the src folder.
      Returns:
      the src folder
    • setSrcFolder

      public void setSrcFolder(String srcFolder)
      Sets the src folder.
      Parameters:
      srcFolder - the new src folder
    • getTargetFolder

      public String getTargetFolder()
      Gets the target folder.
      Returns:
      the target folder
    • setTargetFolder

      public void setTargetFolder(String targetFolder)
      Sets the target folder.
      Parameters:
      targetFolder - the new target folder
    • getJavascriptHtmlSprite

      public Boolean getJavascriptHtmlSprite()
      Gets the javascript html sprite.
      Returns:
      the javascript html sprite
    • setJavascriptHtmlSprite

      public void setJavascriptHtmlSprite(Boolean javascriptHtmlSprite)
      Sets the javascript html sprite.
      Parameters:
      javascriptHtmlSprite - the new javascript html sprite
    • getJavascriptHtmlSpriteIntegrationFile

      public String getJavascriptHtmlSpriteIntegrationFile()
      Gets the javascript html sprite integration file.
      Returns:
      the javascript html sprite integration file
    • setJavascriptHtmlSpriteIntegrationFile

      public void setJavascriptHtmlSpriteIntegrationFile(String javascriptHtmlSpriteIntegrationFile)
      Sets the javascript html sprite integration file.
      Parameters:
      javascriptHtmlSpriteIntegrationFile - the new javascript html sprite integration file
    • getJavascriptHtmlSpriteTargetFile

      public String getJavascriptHtmlSpriteTargetFile()
      Gets the javascript html sprite target file.
      Returns:
      the javascript html sprite target file
    • setJavascriptHtmlSpriteTargetFile

      public void setJavascriptHtmlSpriteTargetFile(String javascriptHtmlSpriteTargetFile)
      Sets the javascript html sprite target file.
      Parameters:
      javascriptHtmlSpriteTargetFile - the new javascript html sprite target file
    • getEncoding

      public String getEncoding()
      Gets the encoding.
      Returns:
      the encoding
    • setEncoding

      public void setEncoding(String encoding)
      Sets the encoding.
      Parameters:
      encoding - the new encoding
    • getClosureCustomExternsOnly

      public Boolean getClosureCustomExternsOnly()
      Gets the closure custom externs only.
      Returns:
      the closure custom externs only
    • setClosureCustomExternsOnly

      public void setClosureCustomExternsOnly(Boolean closureCustomExternsOnly)
      Sets the closure custom externs only.
      Parameters:
      closureCustomExternsOnly - the new closure custom externs only
    • getClosureExterns

      public String[] getClosureExterns()
      Gets the closure externs.
      Returns:
      the closure externs
    • setClosureExterns

      public void setClosureExterns(String[] closureExterns)
      Sets the closure externs.
      Parameters:
      closureExterns - the new closure externs