This project provides a Maven plugin to do one thing: safely "minify" web resources. The key word is "safely": the aim is not to produce maximal size reduction, nor introduce any morphological changes, but to provide reasonable file size reduction in most cases.
You can use minifier-maven-plugin in your projects by including it in
the build/plugins section of your project's POM.
<plugin>
<groupId>net.logicsquad</groupId>
<artifactId>minifier-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>default-minify</id>
<configuration>
<sourceDir>${basedir}/src/main/webserver-resources</sourceDir>
<targetDir>${project.build.directory}/${project.build.finalName}.woa/Contents/WebServerResources</targetDir>
<cssIncludes>
<cssInclude>**/*.css</cssInclude>
</cssIncludes>
<cssExcludes>
<cssExclude>**/*.min.css</cssExclude>
</cssExcludes>
<jsIncludes>
<jsInclude>**/*.js</jsInclude>
</jsIncludes>
<jsExcludes>
<jsExclude>**/*.min.js</jsExclude>
</jsExcludes>
</configuration>
<goals>
<goal>minify</goal>
</goals>
</execution>
</executions>
</plugin>
Mandatory parameters are:
sourceDir: the parent directory in which to scan for resources.targetDir: the corresponding directory in the built package.
The appropriate values for these parameters will vary with the type of project you are trying to build. (The example above shows appropriate values for a WebObjects project.) Relative paths are resolved against the project's base directory.
You can then supply include and exclude patterns to build up lists of filenames of resources to minify. This is done separately for Javascript and CSS, as shown above. The syntax for these patterns follows the standard Maven syntax used by other plugins.
Other optional parameters are:
skip: iftrue, nothing is minified. The user propertyminifier.skipsets it too, as inmvn -Dminifier.skip package.encoding: the encoding the resources are read and written in, UTF-8 by default. The user propertyminifier.encodingsets it too. As in browsers, a resource that starts with a byte order mark, for UTF-8, UTF-16BE or UTF-16LE, is read and written in that encoding instead. A resource that isn't valid in its encoding fails the build.
By all means, open issue tickets and pull requests if you have something to contribute.
Minification is handled by Logic Squad's Minifier project. This project is inspired by Minify Maven Plugin, though aims to be a simpler product.