I am having Java EE application in which I was using ANT in order to do all my tasks. For the minification of JavaScript I was using YUI Compressor and its ANT plugin and used to compress my files during build. Now my problem is that I want to use the default eclipse build and achieve the same result. I want to know that whether is it possible to minify the JavaScript used in my project during the time eclipse builds my project or may be when it creates a war archive ?
I'm personnaly using ant, together with Google's closure compiler, to concatenate and minify all my CSS and javascript file when I'm building my Java EE application.
The steps are
I have something like this :
<target name="minify-m3" depends="init">
<description>build the compacted/minified version </description>
<echo>Concatenating the css...</echo>
<concat destfile="${somevar.dir}/pmc.concat.css">
<fileset dir="${somevar.dir}/skins/contrast">
<filename name="*.css"/>
<not><filename name="**/pmc.concat.css"/></not>
</fileset>
</concat>
<echo>Concatenating javascript...</echo>
<concat destfile="${somevar.dir}/pmc.concat.js">
<!-- Attention : ensure there is no Unicode BOM in the files -->
<!-- attention : keep js files in order! -->
<filelist dir="src/webapp/m3">
<file name="graphic_utils.js" />
<file name="Rect.js" />
...
</filelist>
</concat>
<echo>Concatenating using the Closure Compiler...</echo>
<jscomp compilationLevel="simple" warning="quiet" debug="false" output="${somevar.dir}/pmc.min.js">
<sources dir="src/webapp/m3">
<file name="pmc.concat.js" />
</sources>
</jscomp>
<echo>Finished</echo>
</target>