Friday, November 23, 2012

Getting to know the GWT Compiler

The GWT compiler, copied to gwtcc, compiles Java to Javascript for deployment in web browsers. This is especially interesting for accessing the web graphics available to javascript applications, for example SVG or WebGL.


The GWT Compiler is shown separated from the main GWT build process. This standalone subset (selected) from GWT Revision 11383 (Tue, 20 Nov 2012) shows packaging requirements for use beyond GWT.

The gwtc compiler is driven by a list of module names. Module names use a dot notation that is mapped to a source path module XML file. For example,
maps to a module file

In processing modules, the compiler is directed by the Module XML file to compile java to javascript.

The general process of compiling multiple modules includes application packaging for deployment, as directed by the module files.


The build process for the gwtcc package uses Ant. To build, run

in the gwtcc working directory.

The gwtcc compiler may be run using

    java -jar gwtcc-*.jar [options] modules* 

The compiler's java classpath is defined in the jar file, it depends on the jar files in the lib directory. It will operate correctly from any other directory. For example, an invocation script might look like

    java -jar /home/gwt/src/gwtcc/gwtcc-*.jar [options] modules* 

The gwtcc jar file could be repackaged to include the contents of all of the java class archives, and the manifest attribute main-class.


Beyond GWT, a collection of modules could be defined to establish a javascript platform that is usable by applications.

A platform is one or more precompiled GWT module files named "*.gwtar. These are produced by running

    java -cp gwtcc-*.jar [options] modules* 


A deployment is the compiler's output file tree of javascript. This subtree of javascript and related resources is copied into a web server public location.

No comments: