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 Summary
FieldsModifier and TypeFieldDescriptionprivate booleanDisable default built-in closure externs.private String[]Sets custom closure externs file list.private StringclosureOptLevel = "simple", "advanced" or "whitespace".private booleancompress inline css.private booleancompress inline javascript.private com.googlecode.htmlcompressor.compressor.Compressorcss compressor.private booleanif false all compression is off (default is true).private StringCharset encoding for files to read and create.private String[]Deprecated.use fileExtensionsprivate String[]File extensions to be processed.private booleanHTML compression statistics.private Stringfile where statistics of html compression is stored.private com.googlecode.htmlcompressor.compressor.Compressorjavascript compression.private booleanCreate javascript file which includes all compressed html files as json object.private StringJavaScript sprite integration file (first occurrence of "%s" will be substituted by json with all compressed html strings).private StringThe target JavaScript sprite file with compressed html files as json object.private Stringjavascript compression: "yui" or "closure".private String[]predefined patterns for most often used custom preservation rules: PHP_TAG_PATTERN and SERVER_SCRIPT_TAG_PATTERN.private booleanpreserves original line breaks.private File[]list of files containing preserve patterns.private String[]preserve patterns.private booleanif false keeps HTML comments (default is true).private booleanremove optional attributes from form tags.private booleanreplace "http://" with "//" inside tag attributes.private booleanreplace "https://" with "//" inside tag attributes.private booleanremove optional attributes from input tags.private booleanremoves iter-tag whitespace characters.private booleanremove "javascript:" from inline event handlers.private booleanremove optional attributes from link tags.private booleanif false keeps multiple whitespace characters (default is true).private booleanremoves unnecessary tag attribute quotes.private booleanremove optional attributes from script tags.private booleanremove optional attributes from style tags.private booleanremove values from boolean tag attributes.private booleansimplify existing doctype.private booleanSkip run of plugin.private Stringsource folder where html files are located.private Stringtarget folder where compressed html files will be placed.private int--line-break param for Yahoo YUI Compressor.private boolean--disable-optimizations param for Yahoo YUI Compressor.private int--line-break param for Yahoo YUI Compressor.private boolean--nomunge param for Yahoo YUI Compressor.private boolean--preserve-semi param for Yahoo YUI Compressor.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()Gets the closure custom externs only.String[]Gets the closure externs.Gets the closure opt level.Gets the compress css.Gets the compress java script.Gets the enabled.Gets the encoding.String[]Deprecated.use getFileExtensionsString[]Gets the file ext.Gets the generate statistics.Gets the html compression statistics.Gets the javascript html sprite.Gets the javascript html sprite integration file.Gets the javascript html sprite target file.Gets the js compressor.String[]Gets the predefined preserve patterns.Gets the preserve line breaks.File[]Gets the preserve pattern files.String[]Gets the preserve patterns.Gets the removes the comments.Gets the removes the form attributes.Gets the removes the http protocol.Gets the removes the https protocol.Gets the removes the input attributes.Gets the removes the intertag spaces.Gets the removes the java script protocol.Gets the removes the link attributes.Gets the removes the multi spaces.Gets the removes the quotes.Gets the removes the script attributes.Gets the removes the style attributes.Gets the simple boolean attributes.Gets the simple doctype.Gets the src folder.Gets the target folder.Gets the yui css line break.Gets the yui js disable optimizations.Gets the yui js line break.Gets the yui js no munge.Gets the yui js preserve all semi colons.voidsetClosureCustomExternsOnly(Boolean closureCustomExternsOnly) Sets the closure custom externs only.voidsetClosureExterns(String[] closureExterns) Sets the closure externs.voidsetClosureOptLevel(String closureOptLevel) Sets the closure opt level.voidsetCompressCss(Boolean compressCss) Sets the compress css.voidsetCompressJavaScript(Boolean compressJavaScript) Sets the compress java script.voidsetEnabled(Boolean enabled) Sets the enabled.voidsetEncoding(String encoding) Sets the encoding.voidsetFileExt(String[] fileExt) Deprecated.use setFileExtensionsvoidsetFileExtensions(String[] fileExtensions) Sets the file ext.voidsetGenerateStatistics(Boolean generateStatistics) Sets the generate statistics.voidsetHtmlCompressionStatistics(String htmlCompressionStatistics) Sets the html compression statistics.voidsetJavascriptHtmlSprite(Boolean javascriptHtmlSprite) Sets the javascript html sprite.voidsetJavascriptHtmlSpriteIntegrationFile(String javascriptHtmlSpriteIntegrationFile) Sets the javascript html sprite integration file.voidsetJavascriptHtmlSpriteTargetFile(String javascriptHtmlSpriteTargetFile) Sets the javascript html sprite target file.voidsetJsCompressor(String jsCompressor) Sets the js compressor.voidsetPredefinedPreservePatterns(String[] predefinedPreservePatterns) Sets the predefined preserve patterns.voidsetPreserveLineBreaks(Boolean preserveLineBreaks) Sets the preserve line breaks.voidsetPreservePatternFiles(File[] preservePatternFiles) Sets the preserve pattern files.voidsetPreservePatterns(String[] preservePatterns) Sets the preserve patterns.voidsetRemoveComments(Boolean removeComments) Sets the removes the comments.voidsetRemoveFormAttributes(Boolean removeFormAttributes) Sets the removes the form attributes.voidsetRemoveHttpProtocol(Boolean removeHttpProtocol) Sets the removes the http protocol.voidsetRemoveHttpsProtocol(Boolean removeHttpsProtocol) Sets the removes the https protocol.voidsetRemoveInputAttributes(Boolean removeInputAttributes) Sets the removes the input attributes.voidsetRemoveIntertagSpaces(Boolean removeIntertagSpaces) Sets the removes the intertag spaces.voidsetRemoveJavaScriptProtocol(Boolean removeJavaScriptProtocol) Sets the removes the java script protocol.voidsetRemoveLinkAttributes(Boolean removeLinkAttributes) Sets the removes the link attributes.voidsetRemoveMultiSpaces(Boolean removeMultiSpaces) Sets the removes the multi spaces.voidsetRemoveQuotes(Boolean removeQuotes) Sets the removes the quotes.voidsetRemoveScriptAttributes(Boolean removeScriptAttributes) Sets the removes the script attributes.voidsetRemoveStyleAttributes(Boolean removeStyleAttributes) Sets the removes the style attributes.voidsetSimpleBooleanAttributes(Boolean simpleBooleanAttributes) Sets the simple boolean attributes.voidsetSimpleDoctype(Boolean simpleDoctype) Sets the simple doctype.voidsetSrcFolder(String srcFolder) Sets the src folder.voidsetTargetFolder(String targetFolder) Sets the target folder.voidsetYuiCssLineBreak(Integer yuiCssLineBreak) Sets the yui css line break.voidsetYuiJsDisableOptimizations(Boolean yuiJsDisableOptimizations) Sets the yui js disable optimizations.voidsetYuiJsLineBreak(Integer yuiJsLineBreak) Sets the yui js line break.voidsetYuiJsNoMunge(Boolean yuiJsNoMunge) Sets the yui js no munge.voidsetYuiJsPreserveAllSemiColons(Boolean yuiJsPreserveAllSemiColons) Sets the yui js preserve all semi colons.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
htmlCompressionStatistics
@Parameter(property="htmlcompressor.htmlCompressionStatistics", defaultValue="${project.build.directory}/htmlcompressor/html-compression-statistics.txt") private String htmlCompressionStatisticsfile where statistics of html compression is stored. -
fileExt
Deprecated.use fileExtensionsfile types to be processed. -
fileExtensions
File extensions to be processed. -
enabled
@Parameter(property="htmlcompressor.enabled", defaultValue="true") private boolean enabledif false all compression is off (default is true). -
skip
@Parameter(defaultValue="false", alias="skip", property="skip") private boolean skipSkip run of plugin. -
removeComments
@Parameter(property="htmlcompressor.removeComments", defaultValue="true") private boolean removeCommentsif false keeps HTML comments (default is true). -
removeMultiSpaces
@Parameter(property="htmlcompressor.removeMultiSpaces", defaultValue="true") private boolean removeMultiSpacesif false keeps multiple whitespace characters (default is true). -
removeIntertagSpaces
@Parameter(property="htmlcompressor.removeIntertagSpaces", defaultValue="false") private boolean removeIntertagSpacesremoves iter-tag whitespace characters. -
removeQuotes
@Parameter(property="htmlcompressor.removeQuotes", defaultValue="false") private boolean removeQuotesremoves unnecessary tag attribute quotes. -
simpleDoctype
@Parameter(property="htmlcompressor.simpleDoctype", defaultValue="false") private boolean simpleDoctypesimplify existing doctype. -
removeScriptAttributes
@Parameter(property="htmlcompressor.removeScriptAttributes", defaultValue="false") private boolean removeScriptAttributesremove optional attributes from script tags. -
removeStyleAttributes
@Parameter(property="htmlcompressor.removeStyleAttributes", defaultValue="false") private boolean removeStyleAttributesremove optional attributes from style tags. -
removeLinkAttributes
@Parameter(property="htmlcompressor.removeLinkAttributes", defaultValue="false") private boolean removeLinkAttributesremove optional attributes from link tags. -
removeFormAttributes
@Parameter(property="htmlcompressor.removeFormAttributes", defaultValue="false") private boolean removeFormAttributesremove optional attributes from form tags. -
removeInputAttributes
@Parameter(property="htmlcompressor.removeInputAttributes", defaultValue="false") private boolean removeInputAttributesremove optional attributes from input tags. -
simpleBooleanAttributes
@Parameter(property="htmlcompressor.simpleBooleanAttributes", defaultValue="false") private boolean simpleBooleanAttributesremove values from boolean tag attributes. -
removeJavaScriptProtocol
@Parameter(property="htmlcompressor.removeJavaScriptProtocol", defaultValue="false") private boolean removeJavaScriptProtocolremove "javascript:" from inline event handlers. -
removeHttpProtocol
@Parameter(property="htmlcompressor.removeHttpProtocol", defaultValue="false") private boolean removeHttpProtocolreplace "http://" with "//" inside tag attributes. -
removeHttpsProtocol
@Parameter(property="htmlcompressor.removeHttpsProtocol", defaultValue="false") private boolean removeHttpsProtocolreplace "https://" with "//" inside tag attributes. -
compressCss
@Parameter(property="htmlcompressor.compressCss", defaultValue="false") private boolean compressCsscompress inline css. -
preserveLineBreaks
@Parameter(property="htmlcompressor.preserveLineBreaks", defaultValue="false") private boolean preserveLineBreakspreserves 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 cssCompressorcss compressor. -
compressJavaScript
@Parameter(property="htmlcompressor.compressJavaScript", defaultValue="false") private boolean compressJavaScriptcompress inline javascript. -
jsCompressor
javascript compression: "yui" or "closure". -
javaScriptCompressor
@Parameter(property="htmlcompressor.javaScriptCompressor", defaultValue="") private com.googlecode.htmlcompressor.compressor.Compressor javaScriptCompressorjavascript 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 closureOptLevelclosureOptLevel = "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[] predefinedPreservePatternspredefined patterns for most often used custom preservation rules: PHP_TAG_PATTERN and SERVER_SCRIPT_TAG_PATTERN. -
preservePatterns
preserve patterns. -
preservePatternFiles
list of files containing preserve patterns. -
generateStatistics
@Parameter(property="htmlcompressor.generateStatistics", defaultValue="true") private boolean generateStatisticsHTML compression statistics. -
srcFolder
@Parameter(property="htmlcompressor.srcFolder", defaultValue="${basedir}/src/main/resources") private String srcFoldersource folder where html files are located. -
targetFolder
@Parameter(property="htmlcompressor.targetFolder", defaultValue="${project.build.directory}/classes") private String targetFoldertarget folder where compressed html files will be placed. -
javascriptHtmlSprite
@Parameter(property="htmlcompressor.javascriptHtmlSprite", defaultValue="true") private boolean javascriptHtmlSpriteCreate 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 javascriptHtmlSpriteIntegrationFileJavaScript 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 javascriptHtmlSpriteTargetFileThe target JavaScript sprite file with compressed html files as json object. -
encoding
Charset encoding for files to read and create. -
closureCustomExternsOnly
@Parameter(property="htmlcompressor.closureCustomExternsOnly", defaultValue="false") private boolean closureCustomExternsOnlyDisable default built-in closure externs. -
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
Gets the html compression statistics.- Returns:
- the html compression statistics
-
setHtmlCompressionStatistics
Sets the html compression statistics.- Parameters:
htmlCompressionStatistics- the new html compression statistics
-
getFileExt
Deprecated.use getFileExtensionsGets the file ext.- Returns:
- the file ext
-
setFileExt
Deprecated.use setFileExtensionsSets the file ext.- Parameters:
fileExt- the new file ext
-
getFileExtensions
-
setFileExtensions
Sets the file ext.- Parameters:
fileExtensions- the new file ext
-
getEnabled
-
setEnabled
-
getRemoveComments
-
setRemoveComments
Sets the removes the comments.- Parameters:
removeComments- the new removes the comments
-
getRemoveMultiSpaces
Gets the removes the multi spaces.- Returns:
- the removes the multi spaces
-
setRemoveMultiSpaces
Sets the removes the multi spaces.- Parameters:
removeMultiSpaces- the new removes the multi spaces
-
getRemoveIntertagSpaces
Gets the removes the intertag spaces.- Returns:
- the removes the intertag spaces
-
setRemoveIntertagSpaces
Sets the removes the intertag spaces.- Parameters:
removeIntertagSpaces- the new removes the intertag spaces
-
getRemoveQuotes
-
setRemoveQuotes
Sets the removes the quotes.- Parameters:
removeQuotes- the new removes the quotes
-
getSimpleDoctype
-
setSimpleDoctype
Sets the simple doctype.- Parameters:
simpleDoctype- the new simple doctype
-
getRemoveScriptAttributes
Gets the removes the script attributes.- Returns:
- the removes the script attributes
-
setRemoveScriptAttributes
Sets the removes the script attributes.- Parameters:
removeScriptAttributes- the new removes the script attributes
-
getRemoveStyleAttributes
Gets the removes the style attributes.- Returns:
- the removes the style attributes
-
setRemoveStyleAttributes
Sets the removes the style attributes.- Parameters:
removeStyleAttributes- the new removes the style attributes
-
getRemoveLinkAttributes
Gets the removes the link attributes.- Returns:
- the removes the link attributes
-
setRemoveLinkAttributes
Sets the removes the link attributes.- Parameters:
removeLinkAttributes- the new removes the link attributes
-
getRemoveFormAttributes
Gets the removes the form attributes.- Returns:
- the removes the form attributes
-
setRemoveFormAttributes
Sets the removes the form attributes.- Parameters:
removeFormAttributes- the new removes the form attributes
-
getRemoveInputAttributes
Gets the removes the input attributes.- Returns:
- the removes the input attributes
-
setRemoveInputAttributes
Sets the removes the input attributes.- Parameters:
removeInputAttributes- the new removes the input attributes
-
getSimpleBooleanAttributes
Gets the simple boolean attributes.- Returns:
- the simple boolean attributes
-
setSimpleBooleanAttributes
Sets the simple boolean attributes.- Parameters:
simpleBooleanAttributes- the new simple boolean attributes
-
getRemoveJavaScriptProtocol
Gets the removes the java script protocol.- Returns:
- the removes the java script protocol
-
setRemoveJavaScriptProtocol
Sets the removes the java script protocol.- Parameters:
removeJavaScriptProtocol- the new removes the java script protocol
-
getRemoveHttpProtocol
Gets the removes the http protocol.- Returns:
- the removes the http protocol
-
setRemoveHttpProtocol
Sets the removes the http protocol.- Parameters:
removeHttpProtocol- the new removes the http protocol
-
getRemoveHttpsProtocol
Gets the removes the https protocol.- Returns:
- the removes the https protocol
-
setRemoveHttpsProtocol
Sets the removes the https protocol.- Parameters:
removeHttpsProtocol- the new removes the https protocol
-
getCompressCss
-
setCompressCss
Sets the compress css.- Parameters:
compressCss- the new compress css
-
getPreserveLineBreaks
Gets the preserve line breaks.- Returns:
- the preserve line breaks
-
setPreserveLineBreaks
Sets the preserve line breaks.- Parameters:
preserveLineBreaks- the new preserve line breaks
-
getYuiCssLineBreak
-
setYuiCssLineBreak
Sets the yui css line break.- Parameters:
yuiCssLineBreak- the new yui css line break
-
getCompressJavaScript
Gets the compress java script.- Returns:
- the compress java script
-
setCompressJavaScript
Sets the compress java script.- Parameters:
compressJavaScript- the new compress java script
-
getJsCompressor
-
setJsCompressor
Sets the js compressor.- Parameters:
jsCompressor- the new js compressor
-
getYuiJsNoMunge
-
setYuiJsNoMunge
Sets the yui js no munge.- Parameters:
yuiJsNoMunge- the new yui js no munge
-
getYuiJsPreserveAllSemiColons
Gets the yui js preserve all semi colons.- Returns:
- the yui js preserve all semi colons
-
setYuiJsPreserveAllSemiColons
Sets the yui js preserve all semi colons.- Parameters:
yuiJsPreserveAllSemiColons- the new yui js preserve all semi colons
-
getYuiJsLineBreak
-
setYuiJsLineBreak
Sets the yui js line break.- Parameters:
yuiJsLineBreak- the new yui js line break
-
getClosureOptLevel
-
setClosureOptLevel
Sets the closure opt level.- Parameters:
closureOptLevel- the new closure opt level
-
getYuiJsDisableOptimizations
Gets the yui js disable optimizations.- Returns:
- the yui js disable optimizations
-
setYuiJsDisableOptimizations
Sets the yui js disable optimizations.- Parameters:
yuiJsDisableOptimizations- the new yui js disable optimizations
-
getPredefinedPreservePatterns
Gets the predefined preserve patterns.- Returns:
- the predefined preserve patterns
-
setPredefinedPreservePatterns
Sets the predefined preserve patterns.- Parameters:
predefinedPreservePatterns- the new predefined preserve patterns
-
getPreservePatterns
-
setPreservePatterns
Sets the preserve patterns.- Parameters:
preservePatterns- the new preserve patterns
-
getPreservePatternFiles
Gets the preserve pattern files.- Returns:
- the preserve pattern files
-
setPreservePatternFiles
Sets the preserve pattern files.- Parameters:
preservePatternFiles- the new preserve pattern files
-
getGenerateStatistics
Gets the generate statistics.- Returns:
- the generate statistics
-
setGenerateStatistics
Sets the generate statistics.- Parameters:
generateStatistics- the new generate statistics
-
getSrcFolder
-
setSrcFolder
Sets the src folder.- Parameters:
srcFolder- the new src folder
-
getTargetFolder
-
setTargetFolder
Sets the target folder.- Parameters:
targetFolder- the new target folder
-
getJavascriptHtmlSprite
Gets the javascript html sprite.- Returns:
- the javascript html sprite
-
setJavascriptHtmlSprite
Sets the javascript html sprite.- Parameters:
javascriptHtmlSprite- the new javascript html sprite
-
getJavascriptHtmlSpriteIntegrationFile
Gets the javascript html sprite integration file.- Returns:
- the javascript html sprite integration file
-
setJavascriptHtmlSpriteIntegrationFile
Sets the javascript html sprite integration file.- Parameters:
javascriptHtmlSpriteIntegrationFile- the new javascript html sprite integration file
-
getJavascriptHtmlSpriteTargetFile
Gets the javascript html sprite target file.- Returns:
- the javascript html sprite target file
-
setJavascriptHtmlSpriteTargetFile
Sets the javascript html sprite target file.- Parameters:
javascriptHtmlSpriteTargetFile- the new javascript html sprite target file
-
getEncoding
-
setEncoding
-
getClosureCustomExternsOnly
Gets the closure custom externs only.- Returns:
- the closure custom externs only
-
setClosureCustomExternsOnly
Sets the closure custom externs only.- Parameters:
closureCustomExternsOnly- the new closure custom externs only
-
getClosureExterns
-
setClosureExterns
Sets the closure externs.- Parameters:
closureExterns- the new closure externs
-