nonplus .me

Using Google's Closure Compiler in Phing

Phing is a build tool for automating and managing php deployments. One great feature is the ability to minify your .js files during the build process. Unfortunately Phing uses jsmin to accomplish this instead of the newer, more efficient compilers like Google’s Closure Compiler.

To add minifying via Closure I created this Phing task. The API is very similar to that of jsmin, e.g.

<taskdef name="jsCompile" classname="phing.tasks.my.JsCompileTask" />
<jsCompile compilerPath="docroot/bin/compiler.jar" targetPath="docroot/script/minified" failOnError="false">
    <fileset dir="docroot/script">
        <include name="**/*.js"/>
    </fileset>
</jsCompile>

Happy Phinging!