I'm using this plugin for my jQuery Photoboxr plugin and it works a treat! I did find it's documentation/examples a little limited so wanted to share the configuration that I came up with.
Below is the directory and file structure for my project...
Directory Structure
{$basedir}
|
+--src
| +--css
| +--jquery-ui-photoboxr.css
| +--js
| +--jquery-ui-photoboxr.js
| ...
+--pom.xml
The above structure differs from what the plugin expects. After digging through documentation I found that the default src directory expected is ${basedir}/src/main/webapp which I think is not ideal. Luckily it's easy enough to make the plugin look elsewhere.
I'm going to leave out all the boilerplate POM file content and will just include what's necessary for the Minify plugin. The full pom.xml file is available on Github here.
So lets see the configuration for the plugin...
Plugin configuration
<plugin>
<groupId>com.samaxes.maven</groupId>
<artifactId>minify-maven-plugin</artifactId>
<version>1.7.4</version>
<executions>
<execution>
<id>default-minify</id>
<phase>package</phase>
<goals>
<goal>minify</goal>
</goals>
<configuration>
<webappSourceDir>${basedir}/src</webappSourceDir>
<cssSourceDir>css</cssSourceDir>
<cssSourceFiles>
<cssSourceFile>jquery-ui-photoboxr.css</cssSourceFile>
</cssSourceFiles>
<cssFinalFile>jquery-ui-photoboxr.css</cssFinalFile>
<jsSourceDir>js</jsSourceDir>
<jsSourceFiles>
<jsSourceFile>jquery-ui-photoboxr.js</jsSourceFile>
</jsSourceFiles>
<jsFinalFile>jquery-ui-photoboxr.js</jsFinalFile>
<cssEngine>YUI</cssEngine>
<jsEngine>CLOSURE</jsEngine>
<closureCompilationLevel>SIMPLE_OPTIMIZATIONS</closureCompilationLevel>
</configuration>
</execution>
</executions>
</plugin>
I bind the plugin to the package phase (line 8). The source directory is set to ${basedir}/src (line 14). On lines 16-20 I specify my source CSS file and the name of minified CSS file - the default is style.css. Similarly on lines 22 to 26 I specify the source and output JavaScript files. Finally the last parts of my configuration specify which minification engines should be used.
I found that Closure Compiler produces smaller JavaScript files than YUI.
To run the plugin, it's as simple as...
Maven Command
mvn clean package
This will generate minified versions of the CSS and JavaScript files in the 'target' directory.
Enjoy!
-i