GWT compiler options
Posted by David Chandler on April 14, 2010
There doesn’t appear to be much documentation on GWT compiler options, and what there is refers to an old version (1.6). Fortunately, you can always invoke the compiler on the command line to see a list of options. If you’ve installed GWT using the Google plugin for Eclipse, you’ll find GWT_HOME in your eclipse/plugins directory.
C:\...\gwt-2.0.3>java -cp gwt-dev.jar com.google.gwt.dev.Compiler Missing required argument 'module[s]' Google Web Toolkit 2.0.3 Compiler [-logLevel level] [-workDir dir] [-gen dir] [-style style] [-ea] [-XdisableClassMetadata] [-XdisableCastChecking] [-validateOnly] [-draftCompile] [-compileReport] [-localWorkers count] [-war dir] [-extra dir] module[s] where -logLevel The level of logging detail: ERROR, WARN, INFO, TRACE, DEBUG, SPAM, or ALL -workDir The compiler's working directory for internal use (must be writeable; defaults to a system tem p dir) -gen Debugging: causes normally-transient generated types to be saved in the specified directory -style Script output style: OBF[USCATED], PRETTY, or DETAILED (defaults to OBF) -ea Debugging: causes the compiled output to check assert statements -XdisableClassMetadata EXPERIMENTAL: Disables some java.lang.Class methods (e.g. getName()) -XdisableCastChecking EXPERIMENTAL: Disables run-time checking of cast operations -validateOnly Validate all source code, but do not compile -draftCompile Enable faster, but less-optimized, compilations -compileReport Create a compile report that tells the Story of Your Compile -localWorkers The number of local workers to use when compiling permutations -war The directory into which deployable output files will be written (defaults to 'war') -extra The directory into which extra files, not intended for deployment, will be written and module[s] Specifies the name(s) of the module(s) to compile
To pass one of these options to the GWT compiler within Eclipse, click Advanced in the GWT Compile dialog.
I was particularly interested in the -gen option, which outputs the Java code emitted by GWT generators used by projects such as gwittir and GWTP to somewhat simplify GWT development using MVP and code splitting. More on this forthcoming…
If you haven’t tried it yet, definitely have a look at the -compileReport option also. It generates an HTML report showing the “story of your compile,” including the size of each package and any split points. You’ll find the report in your project’s build directory under extras/project_name/soycReport/compile-report/index.html.