How do you automate Javascript minification for your Java web applications?
We are using Ant task to minify js files with YUICompressor during production build and put result into a separated folder. Then we upload those files to a web server.
Here is an example:
<target name="js.minify" depends="js.preprocess">
<apply executable="java" parallel="false">
<fileset dir="." includes="foo.js, bar.js"/>
<arg line="-jar"/>
<arg path="yuicompressor.jar"/>
<srcfile/>
<arg line="-o"/>
<mapper type="glob" from="*.js" to="*-min.js"/>
<targetfile/>
</apply>
</target>
Round-up post
If you post something new in this thread, edit this post to link to yours.
- Ant
apply
task (using YUI Compressor) - Custom YUI Compressor Ant task
- Maven YUI Compressor plugin
- Granule (for JSP, JSF, Grails, Ant)
- Ant macros for Google Closure compiler
- wro4j (Maven, servlet filters, plain Java, etc)
- ant-yui-compressor (ant task for compressing JS+CSS)
- JAWR
- Minify Maven Plugin
- humpty
- Ant
exec
task using Terser