Closure is a web development tool that was open sourced by Google in 2010.
https://developers.google.com/closure/
The Closure suite of tools consist of 5 useful tools
- Compiler
- Library
- Templating system (Soy)
- Linter
- Stylesheets system
Create a folder called 'closure' to hold the tools in the Closure suite. Once setup is complete you will have 5 folders within this closure folder:
- closure-compiler (svn checkout http://closure-compiler.googlecode.com/svn/trunk/ closure-compiler)
- closure-library (svn checkout http://closure-library.googlecode.com/svn/trunk/ closure-library)
- closure-templates (svn checkout http://closure-templates.googlecode.com/svn/trunk/ closure-templates)
- closure-linter (svn checkout http://closure-linter.googlecode.com/svn/trunk/ closure-linter)
- closure-stylesheets (git clone https://code.google.com/p/closure-stylesheets/)
To setup the Closure tools you will need to checkout all 5 repos. Additionally you will need to build from source a .jar file for three of the projects (the compiler, templating system, and stylesheet system).
Before you can build any of the sources, you'll first need to install Ant if you don't have it already.If you are using Windows, try http://code.google.com/p/winant/.
When installing Ant, be sure to use a Java 1.6 SDK or some later steps may fail.
Docs about Closure's JavaScript compiler: https://developers.google.com/closure/compiler/Project home: https://code.google.com/p/closure-compiler/
Here are the specific checkout and build commands I'm using on my Mac.
svn checkout http://closure-compiler.googlecode.com/svn/trunk/ closure-compiler
cd closure-compiler
ant jar
cd ..
Make sure it ends with a line stating:
Building jar: /closure/closure-compiler/build/compiler.jar
BUILD SUCCESSFUL
Project home: http://code.google.com/p/closure-library/
My checkout command:
svn checkout http://closure-library.googlecode.com/svn/trunk/ closure-library
No building step necessary, just a checkout.
Docs about Closure's templating system: https://developers.google.com/closure/templates/Project home: http://code.google.com/p/closure-templates/
My checkout and build commands:
svn checkout http://closure-templates.googlecode.com/svn/trunk/ closure-templates
cd closure-templates
ant SoyToJsSrcCompiler
cd ..
Make sure it ends with a line stating:
Building jar: /closure/closure-templates/build/SoyToJsSrcCompiler.jar
BUILD SUCCESSFUL
JavaScript Guidelines checked: http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml
Project home: http://code.google.com/p/closure-linter/
Checkout command (setup step is optional. Adds to modify the /usr/local/bin):
svn checkout http://closure-linter.googlecode.com/svn/trunk/ closure-linter
cd closure-linter
cat README
python ./setup.py install
cd ..
After installing, you get two helper applications installed into /usr/local/bin:
gjslint.py - runs the linter and checks for errors.
fixjsstyle.py - tries to fix errors automatically.
Project home: http://code.google.com/p/closure-stylesheets/
Checkout and build commands:
git clone https://code.google.com/p/closure-stylesheets/
cd closure-stylesheets
ant
Make sure it ends with a line stating:
Building jar: /closure/closure-stylesheets/build/closure-stylesheets.jar
BUILD SUCCESSFUL
So now you've got all the Closure tools installed and ready to go! Now how do you use them?