Maven HTMLCompressor Plugin allows to compress HTML/XML files by adding a few lines to the pom file. This plugin uses htmlcompressor library.
See site page here
Project is currently built and release from following fork
The simplest way to start using this plugin is:
1.Enable plugin in your pom.xml
a. javax namespace jsp usage
<build>
<plugins>
<plugin>
<groupId>com.github.hazendaz.maven</groupId>
<artifactId>htmlcompressor-maven-plugin</artifactId>
<version>1.9.2.1</version>
<configuration>
<goalPrefix>htmlcompressor</goalPrefix>
</configuration>
</plugin>
</plugins>
</build>
b. jakarta namespace jsp usage or any other usage if not using jsp's
<build>
<plugins>
<plugin>
<groupId>com.github.hazendaz.maven</groupId>
<artifactId>htmlcompressor-maven-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<goalPrefix>htmlcompressor</goalPrefix>
</configuration>
</plugin>
</plugins>
</build>
2.Put XML and HTML files under src/main/resources
into any underlying
structure as HTMLCompressor will recursively process files
3.For HTML compression, create integration.js
file under
src/main/resources
where html is stored with the contents like below.
It will integrate HTML templates into JavaScript (%s will be replaced
with JSON object and copied to the target folder).
var htmlTemplatesInjector = {
htmlTemplates: %s
};
4.Run maven goals:
mvn htmlcompressor:html
mvn htmlcompressor:xml
5.Check the target folder for output where resources are stored.
Here is demo you can download
More information about HTML/XML compression plugin configuration at wiki page:
Apache License version 2.0
Issues tracking is available on GitHub issues
Bug reports, feature requests, and general inquiries welcome.