Friday, November 22, 2013

Re: Is there way to compile GWT in production mode?

You don't need to compile your module differently depending on which one you want to in devmode or prod mode; this can be done at runtime; see

On Friday, November 22, 2013 1:35:50 AM UTC+1, Vikram Dave wrote:
Thanks for the explanation, Thomas. The issue is, I have two GWT application (two separate projects compiled using GWT)  running on the same page. I am trying to debug an application, but the "isHostedMode" code in the other JS file, generates an alert. 
What I am trying to do is to get rid of "isHostedMode" method generated by GWT in my JS file (I wouldn't want alerts in my production file). 

function isHostedMode(){      var result = false;      try {        var query = $;        return (query.indexOf('gwt.codesvr=') != -1 || (query.indexOf('gwt.hosted=') != -1 || $wnd_0.external && $wnd_0.external.gwtOnLoad)) && query.indexOf('gwt.hybrid') == -1;      }       catch (e) {      }      isHostedMode = function(){        return result;      }      ;      return result;    }
if (isHostedMode()) {      alert('Cross-site hosted mode not yet implemented. See issue ' + '');      return;    }

I changed the linker to use 'xsiframe' as suggested and the code change in the generated code are as follows.

function isHostedMode(){      var query = $;      return query.indexOf('gwt.codesvr.Hello=') != -1 || query.indexOf('gwt.codesvr=') != -1;    }

if (isHostedMode()) {        return computeUrlForResource('Hello.devmode.js');

Is the any flag/property I can set so that above method doesn't get generated?

On Tuesday, November 19, 2013 2:49:34 AM UTC-8, Thomas Broyer wrote:
What GWT calls "production mode" is running the JavaScript generated from the Java code by the GWT compiler, so the very fact of compiling from Java to JavaScript gives you "production mode"; there's no such thing as "compiling in production mode" and "compiling in some other mode" (there's "draftMode" but it's just one way to tweak the compilation process and its output, it's still "production mode").

The <productionMode> configuration in the gwt-maven-plugin applies to the gwt:test goal, not to gwt:compile.

The gwt:compile goal is exactly equivalent to the Ant snippet you gave: it launches the GWT Compiler to compile the Java code to JavaScript.

Note: the other modes are "dev mode" and "super dev mode": "dev mode" runs your code in Java (not JS), and "super dev mode" runs your code in "production mode" but in a way that makes it fast to (re)compile (i.e. not optimized) and using a resilient compiler, which makes it unsuitable for production (you don't just compile your code to JS, you also highjack code into your page with a bookmarklet so that you ask the super dev mode codeserver to recompile the code before serving it)

I thus don't understand what you mean by "I still see Dev mode code in my JS files", what kind of code are you referring to?

On Tuesday, November 19, 2013 3:41:57 AM UTC+1, vikram dave wrote:

I am trying to compile my GWT code in production mode using Maven. I set production mode true (as seen below) in my pom, but I still see Dev mode code in my JS files. I don't want any dev mode code in my production JS file. Is there a way to do this using Maven? Can I set some flag/ property in my pom or *.gwt.xml file? 

            <!-- Compile Using GWT -->















                            <module>${Module Name}</module>






I see that Ant lets you compile in production mode  by using following in build.xml file. Is there a way I can do this in maven? Or using Ant plugin in Maven? (If yes please share an example or point me to a good doc)

  <target name="gwtc" depends="javac" description="GWT compile to JavaScript (production mode)">

    <java failonerror="true" fork="true" classname="">


        <pathelement location="src"/>

        <path refid="project.class.path"/>

        <pathelement location="../../validation-api-1.0.0.GA.jar" />

        <pathelement location="../../validation-api-1.0.0.GA-sources.jar" />


      <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->

      <jvmarg value="-Xmx256M"/>

      <arg line="-war"/>

      <arg value="war"/>

      <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->

      <arg line="${gwt.args}"/>

      <arg value=""/>



You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment