Search code examples
gwtgwt-compiler

What is the difference between draftCompile and optimize 0 options to the GWT Compiler?


I'm trying to improve the speed of GWT compilation, in the GWT documentation I see they provide multiple ways. I was considering optimize and draftCompile arguments passed to the compiler. Documentation gives confusing description:

draftCompile ==> Compile quickly with minimal optimizations.

optimize ==> Sets the optimization level used by the compiler.  0=none 9=maximum.

I'm trying to find difference between these two and should I use both or they have same effect? What's their individual effect? I used optimize 0 and draftCompile together and didn't see any difference in compile time from when I use just optimize 0.
Googled a lot but not getting any precise explanation for this.
I'm new to GWT, (actually tasked to look at one of the legacy projects in my organization).

Looking for insights from experienced GWT programmers on this. Thanks.


Solution

  • Among other things, the "draft" flag sets the optimization level to zero.

    From https://github.com/gwtproject/gwt/blob/c32238861c4d58bc559d303ab44f91ddd4e10685/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerDraftCompile.java, the class that handles the -draftCompile flag:

      public boolean setFlag(boolean value) {
        int optimizeLevel =
            value ? OptionOptimize.OPTIMIZE_LEVEL_DRAFT : OptionOptimize.OPTIMIZE_LEVEL_DEFAULT;
        optimizeOption.setOptimizationLevel(optimizeLevel);
    
        clusterSimilarFunctionsOption.setClusterSimilarFunctions(!value);
        inlineLiteralParametersOption.setInlineLiteralParameters(!value);
        namespaceOption.setNamespace(JsNamespaceOption.PACKAGE);
        if (value) {
          optimizeDataflowOption.setOptimizeDataflow(false);
        }
        ordinalizeEnumsOption.setOrdinalizeEnums(!value);
        removeDuplicateFunctionsOption.setRemoveDuplicateFunctions(!value);
    
        return true;
      }