skip to navigation
skip to content

ClosureBuilder 0.3.7

The Closure Builder is a simple dependency management tool for The Closure compiler

Package Documentation

Installation Instructions

pip install closurebuilder

Configuring project to use with PasteScript

Create new python package

$ paster create MyPackage

Modify MyPackage/

from setuptools import setup, find_packages
import sys, os

version = '0.1'


Go to the MyPackage folder and execute

$ python egg_info

Now, the ClosureBuilder commands are available.

Run the following command to create the ClosureBuilder folder structure

$ paster init

This command will create the following files in mypackage folder


Download latest Closure Library source files and move them into MyPackage/mypackage/closure/closure-library folder. Open sources.txt file and uncomment include directive

# Directories where source files can be found

include closure-library

include directive tells the ClosureBuilder to search source files in specified folder (in our case in closure-library folder). You can specify more than one include directive, e.g.

# Directories where source files can be found

include closure-library
include /home/andrey/some_other_library
include /home/andrey/my_library_1 strictly
include "/home/andrey/my library 2" strictly

Now we are ready to create and compile javascript application.

Creating application

Just execute the following command to create application

$ paster create-app helloworld

This command will create the following files in closure folder


Modify helloworld.js


 * helloworld.Helloworld bootstrap point
 * @final
helloworld.Helloworld.prototype.entrypoint = function()
  alert('Hello World!!!');


Compiling application

Execute the following command to compile your application

$ paster compile helloworld

After successful command execution the compiled files will be placed in closure/compiled/helloworld/ folder.

The ClosureBuilder standalone

If you do not want to use paster, you can use closure-builder command-line script. closure-builder has absolutely the same commands.

To initialize ClosureBuilder folder structure execute the following commands

$ mkdir MyProject
$ cd MyProject
$ closure-builder init

Now you can use closure-builder in the same manner as described above.

File closure-top.txt

NOTE: This file is used only if you use closure-builder command-line script instead of paster

The ClosureBuilder reads this file to obtain meta information of the project. At this moment only 3 fields are used: Author, Author-mail and License.

File compiler-settings.txt

This file declares common compiler settings for all applications in project.

compiler-settings directive closure-compiler option
compiler PATH_TO_JAR java -jar PATH_TO_JAR
charset CHARSET –charset CHARSET
enable error WARNING_CLASS –jscomp_error WARNING_CLASS
enable warning WARNING_CLASS –jscomp_warning WARNING_CLASS
disable warning WARNING_CLASS –jscomp_off WARNING_CLASS
summary detail level LEVEL –summary_detail_level LEVEL
warning level LEVEL –warning_level LEVEL

File sources.txt

This file declares where to search sources files.

To include/exclude all sources in specified folder (recursively):
  • include PATH
  • include PATH loosely (same as include PATH)
  • include PATH strictly
  • exclude PATH
To include/exclude specified source:
  • include source SOURCE
  • include source SOURCE loosely (same as include source SOURCE)
  • include source SOURCE strictly
  • exclude source SOURCE

Distinction between strict and loose inclusion is that strict inclusion causes an error if source provides more than one namespace.

For example, we have A, B, C and D folders. B is A’s subfolder. C is B’s subfolder. D is C’s subfolder.

To include all sources in these folders:

include A

To include all sources in A and B folders only:

include A
exclude C

To include all sources in A and D folders only:

include A
exclude B
include D

File manifest.txt

Appliction directives Description
compile application NAMESPACE Tells the ClosureBuilder to compile application with the given namespace
compile module NAMESPACE:
module directives
Tells the ClosureBuilder to compile the given namespace as the module
scan PATH deprecated, use include strictly instead
scan loose PATH deprecated, use include instead
include PATH see above
include PATH strictly see above
exclude PATH see above
include source SOURCE see above
include source SOURCE strictly see above
exclude source SOURCE see above
set target PATH Defines the root folder where compiled files will be placed
write to FILENAME Defines the filename for application compiled code(relative to the target folder)
write css to FILENAME If specified all css files will be written as single one.
define see closure compiler –define option
enable debug see closure compiler –debug option
add extern see closure compiler –externs option
Module directives Description
set uri REFERENCE Module URL
set metadata:
module metadata
Specifies module metadata. Use goog.module.ModuleInfo.getMeta() to obtain metadata dictionary.
depends on NAMESPACE Tells the ClosureBuilder that this module depends on another module and must be loaded after it
write to FILENAME Defines the filename for module compiled code(relative to the target folder)
Module metadata Description
set KEY VALUE Stores the given value in module metadata dictionary


# Application manifest

compile application myapp
set target ../public

define goog.DEBUG=false

compile module myapp.Module1:
    set uri "/public/js/module1.js"
    set metadata:
        set somemeta1 "meta1"
        set somemeta2 "meta2"
    write to js/module1.js

compile module myapp.Module2:
    set uri "/public/js/module2.js"
    write to js/module2.js

compile module myapp.Module3:
    set uri "/public/js/module3.js"
    depends on myapp.Module1
    depends on myapp.Module2
    write to js/module3.js

write to js/main.js
write css to css/main.css

CSS compilation

The ClosureBuilder can obfuscate CSS-files and generate CSS renaming map for using with goog.getCssName() function. The given feature turns on automaticly, if you use function goog.resource() in your source files. For more information see goog.getCssName().



// now you can use goog.getCssName() to get obfuscated css class name

Module compilation

Add compile module directive to the application manifest file to tell the ClosureBuilder to compile application with specified module. The ClosureBuilder automatically adds the module info and the module url in ModuleManager. Thus, you should not do it manually.

To load the module from your application you can use the following code

  function() {
    alert('myapp.Module1 is loaded');

Note: Do not forget to call goog.module.ModuleManager.setLoaded() to tell the ModuleManager that module was loaded completely


Issue tracker



  • Bug fix: Module information should be added immediately after goog.module.ModuleLoader
  • Bug fix: Modules with the same dependency does not compile
  • Bug fix: Using directives “include”/”exclude” in the manifest.txt causes an error.
  • New directives are available: “include source” and “exclude source”
  • Directive “scan” was deprecated
  • New directives are available instead of “scan” directive: “include” and “exclude”
  • New compiler-settings directive “compiler”
  • Bug fix: directive “add extern” supports now relative and absolute paths
File Type Py Version Uploaded on Size
ClosureBuilder-0.3.7.tar.gz (md5) Source 2010-12-19 3MB