Hoping this will save someone time in the future; whether the future is bright and shiny… or robotic apocalypse. One of the relatively few issues I’ve had with Google Closure was moving from calcdeps (I think that’s what it was called) to ClosureBuilder was setting up a batch file to run it. With calcdeps, it was mostly just naming a bunch of folders, and it did the rest. When I moved to ClosureBuilder, it wasn’t that easy. At first I panicked, and promptly jumped through a second story window, then I decided getting used to the new compiler is healthier in the long run. Turns out that even if ClosureBuilder expects actual namespaces to include, it’s better in the end as it makes it much easier to include/uninclude a particular namespace incase there’s a need to pick and choose. Here’s an example of the batch file I created to compile a “live” (Not test”) version:
python c:/lib/closure/closure-library/closure/bin/closurebuilder.py ^ //Optional if you are running the 32 bit version of jvm/jre --jvm_flags="-d32" ^ //This is where all the closure files exist --root="c:/lib/closure/closure-library/" ^ //This is the folder in the project that has all the JavaScript files. --root="content/script/live/" ^ //Here are the namespaces in that JavaScript folder that I want to include --namespace="src.base.helper.arrayHelper" ^ --namespace="src.base.helper.constants" ^ --namespace="src.base.helper.domCreation" ^ --namespace="src.base.helper.domHelper" ^ --namespace="src.base.helper.events" ^ --namespace="src.base.control.gridBuilder" ^ --namespace="src.base.control.pager" ^ --namespace="src.site.view.mainContent" ^ --namespace="src.site.view.mother" ^ --namespace="src.site.view.tableOfContents" ^ --output_mode=compiled ^ --compiler_jar="c:/lib/closure/compiler.jar" ^ //This is optional if you want the super duper minimized version on compile. // I typically don't use the simple version, because I had found issues where // it works with simple, but not advanced. --compiler_flags="--compilation_level=ADVANCED_OPTIMIZATIONS" ^ //This is where you want to save the compiled result. I've found that it is easier // put the batch file in the web root, and have it use a relative path rather than // having to give it a drive path like c:\web\something\somethingElse\content... --compiler_flags="--generate_exports" > "content/script/live/final.js" //I keep this here for when I have to be on a computer with the 32 bit version of // jrm/jvm. rem --jvm_flags="-d32" ^
As you can see, it’s actually not all that complicated.