TurboManage

David Chandler's Journal of Java Web and Mobile Development

  • David M. Chandler


    Web app developer since 1994 and former Developer Advocate with Google now residing in Colorado. Besides tech, I enjoy landscape photography and share my work at ColoradoPhoto.gallery.

  • Subscribe

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 241 other followers

  • Sleepless Nights…

    April 2010
    S M T W T F S
    « Mar   May »
     123
    45678910
    11121314151617
    18192021222324
    252627282930  
  • Blog Stats

    • 876,388 hits

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.

Advertisements

11 Responses to “GWT compiler options”

  1. Eric Jablow said

    I’m trying to write an Ant task that executes the Compiler class and provides a better way to add the arguments than to put them on a command line, but I don’t under stand Ant well enough, it seems. I’d like to be able to say:


    <gwtc classpathref="my.path">

    <jvmarg>-X256M</jvmarg>

    <module>com.example.MyModule<lt;/module>

    <gwtc&t;

    Do you know of an implementation I could stealborrow?

  2. AlexH said

    Hi David,

    I am involved in a couple of projects using GWT with gwt-presenter. One uses App Engine and the other does not. On both projects I use Maven and am becoming frustrated with the app that runs on App Engine since I shell out to run the App Engine runtime instead of GWT hosted mode.

    For your projects, I was wondering how you manage running GWT applications along with the App Engine runtime in your local development environment. Using Maven (or Ant), I was wondering if you have found a way to run a GWT app in the GWT hosted environment but still have the App Engine runtime be initialized?

    -Alex

    • Alex, I’m using GWT with maven (no AppEngine) and GWT with AppEngine (no maven) via the Google plugin for Eclipse, but fundamentally I don’t see why it would be a problem to use all three together. In your pom.xml under gwt-maven-plugin configuration, you can add extraJVMargs for -javaagent required by AppEngine. Also, the latest Google plugin for Eclipse claims support for maven, but I haven’t tried it yet.

  3. thanks for posting this … same lack of documentation exists (or doesn’t exist) for DevMode – as for Compile, you can get some notes from the tool itself (com.google.gwt.dev.DevMode):

     DevMode [-noserver] [-port port-number | "auto"] [-whitelist whitelist-string] [-blacklist blacklist-string] [-logdir directory] [-logLevel level] [-gen dir] [-bindAddress host-name-or-address] [-codeServerPort port-number | "auto"] [-server servletContainerLauncher[:args]] [-startupUrl url] [-war dir] [-extra dir] [-workDir dir] module[s]
    
     where
       -noserver        Prevents the embedded web server from running
       -port            Specifies the TCP port for the embedded web server (defaults to 8888)
       -whitelist       Allows the user to browse URLs that match the specified regexes (comma or space separated)
       -blacklist       Prevents the user browsing URLs that match the specified regexes (comma or space separated)
       -logdir          Logs to a file in the given directory, as well as graphically
       -logLevel        The level of logging detail: ERROR, WARN, INFO, TRACE, DEBUG, SPAM, or ALL
       -gen             Debugging: causes normally-transient generated types to be saved in the specified directory
       -bindAddress     Specifies the bind address for the code server and web server (defaults to 127.0.0.1)
       -codeServerPort  Specifies the TCP port for the code server (defaults to 9997)
       -server          Specify a different embedded web server to run (must implement ServletContainerLauncher)
       -startupUrl      Automatically launches the specified URL
       -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
       -workDir         The compiler's working directory for internal use (must be writeable; defaults to a system temp dir)
     and
       module[s]        Specifies the name(s) of the module(s) to host
    
  4. Marjan said

    Hi David,

    As far as I know GWT compiler generates some java code when uiBinder is used. I want to see this code and I guess that I should use -gen option. but I don’t know how should I do it. I’m using Netbeans. I went to the properties of the project then in build/compiling section, there is a box for additional compiler options but I don’t know what’s its syntax, something like -gen: directoryURl?
    would you please help me, I searched so much but couldn’t find anything…

    Thanks

  5. The GWT docs have been updated to include compiler options:

    http://code.google.com/webtoolkit/doc/latest/DevGuideCompilingAndDebugging.html#DevGuideCompilerOptions

  6. Manoj said

    Hi David,
    i want to setup debug for gwt code. my project is j2ee. on compiling gwt with ant the class files were missing. how set up debug in the sense how to src and class path.

  7. Manoj said

    Hi David,
    i want to setup debug for gwt code. my project is j2ee. on compiling gwt with ant the class files were missing. how set up debug in the sense how to src and class path. plz help!!

  8. Cengiz said

    To set GWT compiler arguments from GPE, right-click on your project, select Google->GWT Compile, and expand the Advanced section.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: