2

How do I disable pruning in the GWT compiler?

(I'm trying to use the GWT compiler to create a Javascript version of a some game logic written in Java)

Maybe pruning is not the issue? I'm testing with the following Java class and none of the fields or the string "test123" are in the generated .js file;

Test1.java

package com.joyplay.web.games.mmrb.shared.d1;

public class Test1 {
    public String field1;
    public int field2=0;

    public void onModuleLoad() {
        field1 = "test123";
    }

    public int doSomething1(int a){
        return a+555;
    }

    public int doSomething2(){
        return ++field2;
    }    
}

Test1.gwt.xml

<module rename-to="hello">
    <inherits name="com.google.gwt.core.Core" />
    <source path="d1"/>
    <entry-point class="com.joyplay.web.games.mmrb.shared.d1.Test1"/>
</module>
  • Which .js file are you looking at? Your compiled code will actually be in an [html file](http://code.google.com/webtoolkit/doc/latest/DevGuideCompilingAndDebugging.html#key_application_files) that can be cached. The file you may be looking at if it has a nocache.js will never include any of your application code. – Terrell Plotzki Sep 26 '11 at 21:07

3 Answers3

0

(I'm trying to use the GWT compiler to create a Javascript version of a some game logic written in Java)

Have a look at the gwt-exporter project.

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
0

GWT compiler will remove all of the code above, since it is doing nothing. You can turn off optimization using -draftCompile or -optimize 0 flags

jusio
  • 9,850
  • 1
  • 42
  • 57
-1

Mainly this depends on how you build it.

For maven:

<gwt.jsStyle>PRETTY</gwt.jsStyle>

Or regarding to the official documentation:

-style Script output style: OBF[USCATED], PRETTY, or DETAILED (defaults to OBF)

Igor Konoplyanko
  • 9,176
  • 6
  • 57
  • 100